Package org.eclipse.swt.widgets

Examples of org.eclipse.swt.widgets.Sash


   */
  public void init(Control first, Control second,
      int sasherStyle, int percent) {
    this.sashStyle = sasherStyle;

    sash = new Sash(this, sashStyle);

    // create position instructions
    FormData firstData = new FormData();
    final FormData sashData = new FormData();
    FormData secondData = new FormData();
View Full Code Here


  private void hookSashListeners() {
    purgeSashes();
    Control [] children = getChildren();
    for (int i=0; i<children.length; i++) {
      if (children[i] instanceof Sash) {
        Sash sash = (Sash)children[i];
        if (sashes.contains(sash))
          continue;
        sash.addListener(SWT.Paint, listener);
        sash.addListener(SWT.MouseEnter, listener);
        sash.addListener(SWT.MouseExit, listener);
        sashes.add(sash);
      }
    }
  }
View Full Code Here

      }
    }
  }
  private void purgeSashes() {
    for (Iterator iter=sashes.iterator(); iter.hasNext();) {
      Sash sash = (Sash)iter.next();
      if (sash.isDisposed())
        iter.remove();
    }
  }
View Full Code Here

        iter.remove();
    }
  }

   private void onSashPaint(Event e) {
        Sash sash = (Sash)e.widget;
        FormColors colors = managedForm.getToolkit().getColors();
        boolean vertical = (sash.getStyle() & SWT.VERTICAL)!=0;
        GC gc = e.gc;
        Boolean hover = (Boolean)sash.getData("hover"); //$NON-NLS-1$
        gc.setBackground(colors.getColor(IFormColors.TB_BG));
        gc.setForeground(colors.getColor(IFormColors.TB_BORDER));
        Point size = sash.getSize();
        if (vertical) {
            if (hover!=null)
                gc.fillRectangle(0, 0, size.x, size.y);
            //else
                //gc.drawLine(1, 0, 1, size.y-1);
View Full Code Here

    sashFormData = new FormData();
    sashFormData.width = 1;
    sashFormData.top = new FormAttachment(0, 0);
    sashFormData.left = new FormAttachment(0, 200);
    sashFormData.bottom = new FormAttachment(100, 0);
    final Sash sash = new Sash(form.getBody(), SWT.VERTICAL);
    sash.setBackground(toolkit.getColors().getBorderColor());
    sash.setLayoutData(sashFormData);
    sash.addListener(SWT.Selection, new Listener() {
      @Override
      public void handleEvent(Event e) {
        ((FormData) sash.getLayoutData()).left = new FormAttachment(0, e.x);
        sash.getParent().layout();
      }
    });

    // Extension list:
    FormData leftData = new FormData();
View Full Code Here

    int sashStyle =
      (orientation == SWT.HORIZONTAL) ? SWT.VERTICAL : SWT.HORIZONTAL;

    Control c;
    /*if(liveUpdate) c = new SashCanvas(this, sashStyle);
    else*/ c = new Sash(this, sashStyle);
    final Control sash = c;

    sash.setBackground(background);
    sash.setForeground(foreground);
    sash.addListener(SWT.Selection, sashListener);
View Full Code Here

      parent.setBackground(color);
     
        _mainComposite = new Composite(parent, SWT.NONE);
        _mainComposite.setBackground(color);
        _leftComposite = new Composite(_mainComposite, SWT.NONE);
        _sash = new Sash(_mainComposite, SWT.VERTICAL);
        _rightComposite = new Composite(_mainComposite, SWT.NONE);

        color = new Color(Display.getCurrent(), 0, 120, 100);
        _rightComposite.setBackground(color);
       
View Full Code Here

    this.leftControl = leftControl;
    this.rightControl = rightControl;
    this.parent = parent;
    this.fixLeftWidth = fixLeftControl;

    sash = new Sash(parent, SWT.VERTICAL);
    parent.setLayout(new FormLayout());

    fdLeft = new FormData();
    fdLeft.left = new FormAttachment(0, 0);
    fdLeft.right = new FormAttachment(sash, 0);
View Full Code Here

     * Left,Rigth,Top and Botton sashes. The elements
     * may be null depending whether there is a shash
     * beside the <code>part</code>
     */
    void findSashes(LayoutTree child, PartPane.Sashes sashes) {
        Sash sash = (Sash) getSash().getControl();
        boolean leftOrTop = children[0] == child;
        if (sash != null) {
            LayoutPartSash partSash = getSash();
            //If the child is in the left, the sash
            //is in the rigth and so on.
View Full Code Here

      return// We have a maximized control, so we don't need to worry about the sash.
     
    // Let's get the list of all sashes the sash form now has. If there is more than one then just disable the sashinfo.
    // If there is no current sash, and there is only one sash, then create the sashinfo for it.
    Control[] children = getChildren();
    Sash newSash = null;
    for (int i = 0; i < children.length; i++) {
      if (children[i] instanceof Sash)
        if (newSash == null)
          newSash = (Sash) children[i];
        else {
          // We have more than one sash, so need to disable current sash, if we have one.
          if (currentSashInfo != null)
            currentSashInfo.enabled = false;
          return// Don't go on.
       
    }
   
    if (newSash == null)
      return// We have no sashes at all.
   
    // Now we need to see if this is a new sash.
    if (currentSashInfo == null || currentSashInfo.sash == null) {
      if (currentSashInfo == null)
        currentSashInfo = new SashInfo(newSash);
      else
        currentSashInfo.sash = newSash;
      newSash.addPaintListener(new PaintListener() {
        /**
         * @see org.eclipse.swt.events.PaintListener#paintControl(PaintEvent)
         */
        public void paintControl(PaintEvent e) {
          // Need to find the index of the sash we're interested in.
         
          GC gc = e.gc;
          Color oldFg = gc.getForeground();
          Color oldBg = gc.getBackground();
         
          drawArrow(gc, currentSashInfo.sashLocs[0], currentSashInfo.cursorOver == 0)// Draw first arrow
          if (currentSashInfo.sashLocs.length > 1)
            drawArrow(gc, currentSashInfo.sashLocs[1], currentSashInfo.cursorOver == 1)// Draw second arrow         
         
          if (currentSashInfo.sashBorderLeft)
            drawSashBorder(gc, currentSashInfo.sash, true);
          if (currentSashInfo.sashBorderRight)
            drawSashBorder(gc, currentSashInfo.sash, false);
           
          gc.setForeground(oldFg);
          gc.setBackground(oldBg);
        }

      });
     
      newSash.addControlListener(new ControlListener() {
        /**
         * @see org.eclipse.swt.events.ControlAdapter#controlMoved(ControlEvent)
         */
        public void controlMoved(ControlEvent e) {
          recomputeSashInfo();
        }
       
        /**
         * @see org.eclipse.swt.events.ControlAdapter#controlResized(ControlEvent)
         */
        public void controlResized(ControlEvent e) {
          recomputeSashInfo();
        }
               

      });
     
      newSash.addDisposeListener(new DisposeListener() {
        /**
         * @see org.eclipse.swt.events.DisposeListener#widgetDisposed(DisposeEvent)
         */
        public void widgetDisposed(DisposeEvent e) {
          // Need to clear out the widget from current.
          currentSashInfo= null;
        }
      });
     
      // This is a kludge because we can't override the set cursor hit test.
      newSash.addMouseMoveListener(new MouseMoveListener() {
        /**
         * @see org.eclipse.swt.events.MouseMoveListener#mouseMove(MouseEvent)
         */
        public void mouseMove(MouseEvent e) {
          // See if within one of the arrows.
          int x = e.x;
          int y = e.y;
          for (int i=0; i<currentSashInfo.sashLocs.length; i++) {
            int[] locs = currentSashInfo.sashLocs[i];
            boolean vertical = getOrientation() == SWT.VERTICAL;
            int loc = vertical ? x : y;
            int locIndex = vertical ? X_INDEX : Y_INDEX;
            int sizeIndex = vertical ? WIDTH_INDEX : HEIGHT_INDEX;
            if (locs[locIndex] <= loc && loc <= locs[locIndex]+locs[sizeIndex]) {         
//              if (currentSashInfo.cursorOver == NO_ARROW) {
//                currentSashInfo.sash.setCursor(Cursors.ARROW);
//              }
              if (currentSashInfo.cursorOver != i) {
                currentSashInfo.cursorOver = i;
                currentSashInfo.sash.redraw();
                switch (locs[ARROW_TYPE_INDEX]) {
                  case UP_ARROW:
                  case DOWN_ARROW:
                    currentSashInfo.sash.setToolTipText("Restore")//$NON-NLS-1$
                    break;
                  case UP_MAX_ARROW:
                  case DOWN_MAX_ARROW:
                    currentSashInfo.sash.setToolTipText("Maximize")//$NON-NLS-1$
                    break;
                }
              }
              return;
            }
          }
          if (currentSashInfo.cursorOver != NO_ARROW) {
            currentSashInfo.sash.setCursor(null);
            currentSashInfo.cursorOver = NO_ARROW;
            currentSashInfo.sash.redraw();
            currentSashInfo.sash.setToolTipText(null);
          }
        }
       
      });
     
      // Need to know when we leave so that we can clear the cursor feedback if set.
      newSash.addMouseTrackListener(new MouseTrackAdapter() {
        /**
         * @see org.eclipse.swt.events.MouseTrackAdapter#mouseExit(MouseEvent)
         */
        public void mouseExit(MouseEvent e) {
          if (currentSashInfo.cursorOver != NO_ARROW) {
            // Undo the cursor.
            currentSashInfo.sash.setCursor(null);
            currentSashInfo.cursorOver = NO_ARROW;
            currentSashInfo.sash.redraw();
            currentSashInfo.sash.setToolTipText(null);
          }           
        }       
      });
     
      // Want to handle mouse down as a selection.
      newSash.addMouseListener(new MouseAdapter() {
        /**
         * @see org.eclipse.swt.events.MouseAdapter#mouseDown(MouseEvent)
         */
        public void mouseDown(MouseEvent e) {
          inMouseClick = true;
View Full Code Here

TOP

Related Classes of org.eclipse.swt.widgets.Sash

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.