org.eclipse.swt.widgets.Shell.setRegion()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(10.2k)|赞(0)|评价(0)|浏览(125)

本文整理了Java中org.eclipse.swt.widgets.Shell.setRegion()方法的一些代码示例,展示了Shell.setRegion()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Shell.setRegion()方法的具体详情如下:
包路径:org.eclipse.swt.widgets.Shell
类名称:Shell
方法名:setRegion

Shell.setRegion介绍

[英]Sets the shape of the shell to the region specified by the argument. When the argument is null, the default shape of the shell is restored. The shell must be created with the style SWT.NO_TRIM in order to specify a region.

NOTE: This method also sets the size of the shell. Clients should not call #setSize or #setBounds on this shell. Furthermore, the passed region should not be modified any more.
[中]将壳的形状设置为参数指定的区域。当参数为null时,将恢复外壳的默认形状。外壳必须使用SWT样式创建。不修剪以指定区域。
注意:此方法还可以设置壳的大小。客户不应该在这个外壳上调用#setSize或#setBounds。此外,不应再修改已通过的区域。

代码示例

代码示例来源:origin: org.eclipse.platform/org.eclipse.jface

void setNewShape() {
    Region oldRegion = region;
    region = new Region();
    region.add(getPolygon(false));
    hoverShell.setRegion(region);
    if (oldRegion != null) {
      oldRegion.dispose();
    }
  }
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.m2e.core.ui

void setNewShape() {
  Region oldRegion = region;
  region = new Region();
  region.add(getPolygon(false));
  hoverShell.setRegion(region);
  if(oldRegion != null) {
   oldRegion.dispose();
  }
 }
}

代码示例来源:origin: org.eclipse.e4.ui.workbench.addons/swt

private void updateRegion() {
  Region region = new Region();
  for (Adornment adornment : adornments) {
    adornment.updateRegion(region);
  }
  overlayShell.setRegion(region);
  if (!overlayShell.getVisible())
    overlayShell.setVisible(true);
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench

@Override
public void initialize(AnimationEngine engine) {
  Color color = getAnimationShell().getDisplay().getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW);
  getAnimationShell().setBackground(color);
  // Ensure that the background won't show on the initial display
  shellRegion = new Region(getAnimationShell().getDisplay());
  getAnimationShell().setRegion(shellRegion);
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface

void setNewShape() {
    Region oldRegion = region;
    region = new Region();
    region.add(getPolygon(false));
    hoverShell.setRegion(region);
    if (oldRegion != null) {
      oldRegion.dispose();
    }
  }
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.jface

void setNewShape() {
    Region oldRegion = region;
    region = new Region();
    region.add(getPolygon(false));
    hoverShell.setRegion(region);
    if (oldRegion != null) {
      oldRegion.dispose();
    }
  }
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface

void setNewShape() {
    Region oldRegion = region;
    region = new Region();
    region.add(getPolygon(false));
    hoverShell.setRegion(region);
    if (oldRegion != null) {
      oldRegion.dispose();
    }
  }
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.e4.ui.workbench.addons.swt

private void updateRegion() {
  Region region = new Region();
  for (Adornment adornment : adornments) {
    adornment.updateRegion(region);
  }
  overlayShell.setRegion(region);
  if (!overlayShell.getVisible()) {
    overlayShell.setVisible(true);
  }
}

代码示例来源:origin: org.eclipse/org.eclipse.jdt.ui

private void packPopup() {
  boolean isUnderLeft= fSnapPosition == SNAP_POSITION_UNDER_LEFT_FIELD;
  boolean isOverLeft= fSnapPosition == SNAP_POSITION_OVER_LEFT_FIELD;
  fPopupLayout.marginTop= isUnderLeft ? HAH : 0;
  fPopupLayout.marginBottom= isOverLeft ? HAH + 1 : 0;
  fPopup.pack();
  
  Region oldRegion= fRegion;
  if (isUnderLeft || isOverLeft) {
    fRegion= new Region();
    fRegion.add(getPolygon(false));
    fPopup.setRegion(fRegion);
    Rectangle bounds= fRegion.getBounds();
    fPopup.setSize(bounds.width, bounds.height + 1);
  } else {
    fRegion= null;
    fPopup.setRegion(null);
  }
  
  if (oldRegion != null) {
    oldRegion.dispose();
  }
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench

@Override
public void renderStep(AnimationEngine engine) {
  if (shellRegion != null) {
    shellRegion.dispose();
    shellRegion = new Region(getAnimationShell().getDisplay());
  }
  // Iterate across the set of start/end rects
  Iterator currentRects = getCurrentRects(engine.amount()).iterator();
  while (currentRects.hasNext()) {
    Rectangle curRect = (Rectangle) currentRects.next();
    Rectangle rect = Geometry.toControl(getAnimationShell(), curRect);
    shellRegion.add(rect);
    rect.x += LINE_WIDTH;
    rect.y += LINE_WIDTH;
    rect.width = Math.max(0, rect.width - 2 * LINE_WIDTH);
    rect.height = Math.max(0, rect.height - 2 * LINE_WIDTH);
    shellRegion.subtract(rect);
  }
  getAnimationShell().setRegion(shellRegion);
  getAnimationShell().getDisplay().update();
}

代码示例来源:origin: org.xworker/xworker_swt

public static void create(ActionContext actionContext){
    Thing self = (Thing) actionContext.get("self");
    Widget parent = (Widget) actionContext.get("parent");
    
    String regions = self.getStringBlankAsNull("regions");
    if(regions != null){
      String[] ss = regions.split("[,]");
      int[] rs = new int[ss.length];
      for(int i=0;i<ss.length; i++){
        rs[i] = Integer.parseInt(ss[i]);
      }
      
      final Region region =new Region();
      region.add(rs);
      parent.addDisposeListener(new DisposeListener(){
        @Override
        public void widgetDisposed(DisposeEvent arg0) {
          region.dispose();
        }
      });
      
      if(parent instanceof Shell){
        ((Shell) parent).setRegion(region);
      }
    }
  }
}

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.ui

private void packPopup() {
  if (!fSnapPositionChanged) {
    return;
  }
  fSnapPositionChanged= false;
  
  boolean isUnderLeft= fSnapPosition == SNAP_POSITION_UNDER_LEFT_FIELD;
  boolean isOverLeft= fSnapPosition == SNAP_POSITION_OVER_LEFT_FIELD;
  fPopupLayout.marginTop= isUnderLeft ? HAH : 0;
  fPopupLayout.marginBottom= isOverLeft ? HAH + 1 : 0;
  fPopup.pack();
  Region oldRegion= fRegion;
  if (isUnderLeft || isOverLeft) {
    fRegion= new Region();
    fRegion.add(getPolygon(false));
    fPopup.setRegion(fRegion);
    Rectangle bounds= fRegion.getBounds();
    fPopup.setSize(bounds.width, bounds.height + 1);
  } else {
    fRegion= null;
    fPopup.setRegion(null);
  }
  if (oldRegion != null) {
    oldRegion.dispose();
  }
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui

private void packPopup() {
  if (!fSnapPositionChanged) {
    return;
  }
  fSnapPositionChanged= false;
  
  boolean isUnderLeft= fSnapPosition == SNAP_POSITION_UNDER_LEFT_FIELD;
  boolean isOverLeft= fSnapPosition == SNAP_POSITION_OVER_LEFT_FIELD;
  fPopupLayout.marginTop= isUnderLeft ? HAH : 0;
  fPopupLayout.marginBottom= isOverLeft ? HAH + 1 : 0;
  fPopup.pack();
  Region oldRegion= fRegion;
  if (isUnderLeft || isOverLeft) {
    fRegion= new Region();
    fRegion.add(getPolygon(false));
    fPopup.setRegion(fRegion);
    Rectangle bounds= fRegion.getBounds();
    fPopup.setSize(bounds.width, bounds.height + 1);
  } else {
    fRegion= null;
    fPopup.setRegion(null);
  }
  if (oldRegion != null) {
    oldRegion.dispose();
  }
}

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.ui

protected void refresh() {
  adjustItemNumber();
  if (fInput == null)
    return;
  if (fInput.fAnnotations == null)
    return;
  if (fInput.fViewer != null)
    fInput.fViewer.addViewportListener(fViewportListener);
  fShell.setRegion(fLayouter.getShellRegion(fInput.fAnnotations.length));
  Layout layout= fLayouter.getLayout(fInput.fAnnotations.length);
  fComposite.setLayout(layout);
  Control[] children= fComposite.getChildren();
  for (int i= 0; i < fInput.fAnnotations.length; i++) {
    Canvas canvas= (Canvas) children[i];
    Item item= new Item();
    item.canvas= canvas;
    item.fAnnotation= fInput.fAnnotations[i];
    canvas.setData(item);
    canvas.redraw();
  }
}

代码示例来源:origin: org.eclipse/org.eclipse.jdt.ui

protected void refresh() {
  adjustItemNumber();
  if (fInput == null)
    return;
  if (fInput.fAnnotations == null)
    return;
  if (fInput.fViewer != null)
    fInput.fViewer.addViewportListener(fViewportListener);
  fShell.setRegion(fLayouter.getShellRegion(fInput.fAnnotations.length));
  Layout layout= fLayouter.getLayout(fInput.fAnnotations.length);
  fComposite.setLayout(layout);
  Control[] children= fComposite.getChildren();
  for (int i= 0; i < fInput.fAnnotations.length; i++) {
    Canvas canvas= (Canvas) children[i];
    Item item= new Item();
    item.canvas= canvas;
    item.fAnnotation= fInput.fAnnotations[i];
    canvas.setData(item);
    canvas.redraw();
  }
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui

protected void refresh() {
  adjustItemNumber();
  if (fInput == null)
    return;
  if (fInput.fAnnotations == null)
    return;
  if (fInput.fViewer != null)
    fInput.fViewer.addViewportListener(fViewportListener);
  fShell.setRegion(fLayouter.getShellRegion(fInput.fAnnotations.length));
  Layout layout= fLayouter.getLayout(fInput.fAnnotations.length);
  fComposite.setLayout(layout);
  Control[] children= fComposite.getChildren();
  for (int i= 0; i < fInput.fAnnotations.length; i++) {
    Canvas canvas= (Canvas) children[i];
    Item item= new Item();
    item.canvas= canvas;
    item.fAnnotation= fInput.fAnnotations[i];
    canvas.setData(item);
    canvas.redraw();
  }
}

代码示例来源:origin: org.eclipse.e4.ui.workbench.addons/swt

public void setDragHost(Shell hostingShell, int xOffset, int yOffset) {
  dragHost = hostingShell;
  offsetX = xOffset;
  offsetY = yOffset;
  dragHostBounds = null;
  if (dragHost == null)
    return;
  // Punch a 'hole' where the cursor is using a region
  Region rgn = dragHost.getRegion();
  // if (rgn != null && !rgn.isDisposed())
  // rgn.dispose();
  // rgn = new Region(display);
  Rectangle bounds = dragHost.getBounds();
  rgn.add(0, 0, bounds.width, bounds.height);
  rgn.subtract(offsetX, offsetY, 1, 1);
  dragHost.setRegion(rgn);
  initialHostSize = dragHost.getSize();
  // Do an initial 'track'
  Point curLoc = dragHost.getDisplay().getCursorLocation();
  dragHost.setLocation(curLoc.x - offsetX, curLoc.y - offsetY);
  dragHost.layout(true);
}

代码示例来源:origin: org.eclipse.xtext/ui

protected void packPopup() {
  popupLayout.marginTop = HAH;
  popupLayout.marginBottom = 0;
  popup.pack();
  Region oldRegion = region;
  region = new Region();
  region.add(getPolygon(false));
  popup.setRegion(region);
  Rectangle bounds = region.getBounds();
  popup.setSize(bounds.width, bounds.height + 2);
  if (oldRegion != null) {
    oldRegion.dispose();
  }
}

代码示例来源:origin: org.eclipse.e4.ui.workbench.addons/swt

private void defineRegion() {
  Region rgn = new Region();
  for (Rectangle r : rects) {
    rgn.add(r);
    rgn.subtract(r.x + 2, r.y + 2, r.width - 4, r.height - 4);
  }
  if (feedbackShell.getRegion() != null && !feedbackShell.getRegion().isDisposed())
    feedbackShell.getRegion().dispose();
  feedbackShell.setRegion(rgn);
  feedbackShell.redraw();
  display.update();
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.e4.ui.workbench.addons.swt

private void defineRegion() {
  Region rgn = new Region();
  for (Rectangle r : rects) {
    rgn.add(r);
    rgn.subtract(r.x + 2, r.y + 2, r.width - 4, r.height - 4);
  }
  // Workaround: Some window managers draw a drop shadow even if the shell
  // is set to NO_TRIM. By making the shell contain a component in the
  // bottom-right of its parent shell, SWT won't resize it and any extra
  // shadows will end up being drawn on top of the shadows for the parent
  // shell rather than in the middle of the workbench window.
  Composite parent = feedbackShell.getParent();
  if (parent instanceof Shell) {
    Shell parentShell = (Shell) parent;
    Rectangle bounds = parentShell.getBounds();
    rgn.add(bounds.width - 1, bounds.height - 1, 1, 1);
  }
  if (feedbackShell.getRegion() != null && !feedbackShell.getRegion().isDisposed()) {
    feedbackShell.getRegion().dispose();
  }
  feedbackShell.setRegion(rgn);
  feedbackShell.redraw();
  display.update();
}

相关文章

微信公众号

最新文章

更多

Shell类方法