Package org.eclipse.swt.graphics

Examples of org.eclipse.swt.graphics.Region


   * @param region
   * @return region previously assigned to the window.
   */
  public static Region setRegion(int handle, Region region)
  {
    Region prevRegion = Region.win32_new(null, Extension.GetWindowRgn(handle, 0));
    Extension.SetWindowRgn(handle, region.handle, true);
    return prevRegion;
  }
View Full Code Here


    if ((parent.getStyle() & SWT.MIRRORED) != 0 && (style & SWT.LEFT_TO_RIGHT) == 0) return style;
   
    return style | SWT.NO_BACKGROUND;
  }
  static void fillRegion(GC gc, Region region) {
    Region clipping = new Region();
    gc.getClipping(clipping);
    region.intersect(clipping);
    gc.setClipping(region);
    gc.fillRectangle(region.getBounds());
    gc.setClipping(clipping);
    clipping.dispose();
  }
View Full Code Here

    }
    int y = onBottom ? size.y - borderBottom - height : borderTop;
    drawBackground(gc, shape, x, y, width, height, defaultBackground, image, colors, percents, vertical);
  }
  void drawBackground(GC gc, int[] shape, int x, int y, int width, int height, Color defaultBackground, Image image, Color[] colors, int[] percents, boolean vertical) {
    Region clipping = new Region();
    gc.getClipping(clipping);
    Region region = new Region();
    region.add(shape);
    region.intersect(clipping);
    gc.setClipping(region);
   
    if (image != null) {
      // draw the background image in shape
      gc.setBackground(defaultBackground);
      gc.fillRectangle(x, y, width, height);
      Rectangle imageRect = image.getBounds();
      gc.drawImage(image, imageRect.x, imageRect.y, imageRect.width, imageRect.height, x, y, width, height);
    } else if (colors != null) {
      // draw gradient
      if (colors.length == 1) {
        Color background = colors[0] != null ? colors[0] : defaultBackground;
        gc.setBackground(background);
        gc.fillRectangle(x, y, width, height);
      } else {
        if (vertical) {
          if (onBottom) {
            int pos = 0;
            if (percents[percents.length - 1] < 100) {
              pos = percents[percents.length - 1] * height / 100;
              gc.setBackground(defaultBackground);
              gc.fillRectangle(x, y, width, pos);
            }
            Color lastColor = colors[colors.length-1];
            if (lastColor == null) lastColor = defaultBackground;
            for (int i = percents.length-1; i >= 0; i--) {
              gc.setForeground(lastColor);
              lastColor = colors[i];
              if (lastColor == null) lastColor = defaultBackground;
              gc.setBackground(lastColor);
              int gradientHeight = percents[i] * height / 100;
              gc.fillGradientRectangle(x, y+pos, width, gradientHeight, true);
              pos += gradientHeight;
            }
          } else {
            Color lastColor = colors[0];
            if (lastColor == null) lastColor = defaultBackground;
            int pos = 0;
            for (int i = 0; i < percents.length; i++) {
              gc.setForeground(lastColor);
              lastColor = colors[i + 1];
              if (lastColor == null) lastColor = defaultBackground;
              gc.setBackground(lastColor);
              int gradientHeight = percents[i] * height / 100;
              gc.fillGradientRectangle(x, y+pos, width, gradientHeight, true);
              pos += gradientHeight;
            }
            if (pos < height) {
              gc.setBackground(defaultBackground);
              gc.fillRectangle(x, pos, width, height-pos+1);
            }
          }
        } else { //horizontal gradient
          y = 0;
          height = getSize().y;
          Color lastColor = colors[0];
          if (lastColor == null) lastColor = defaultBackground;
          int pos = 0;
          for (int i = 0; i < percents.length; ++i) {
            gc.setForeground(lastColor);
            lastColor = colors[i + 1];
            if (lastColor == null) lastColor = defaultBackground;
            gc.setBackground(lastColor);
            int gradientWidth = (percents[i] * width / 100) - pos;
            gc.fillGradientRectangle(x+pos, y, gradientWidth, height, false);
            pos += gradientWidth;
          }
          if (pos < width) {
            gc.setBackground(defaultBackground);
            gc.fillRectangle(x+pos, y, width-pos, height);
          }
        }
      }
    } else {
      // draw a solid background using default background in shape
      if ((getStyle() & SWT.NO_BACKGROUND) != 0 || !defaultBackground.equals(getBackground())) {
        gc.setBackground(defaultBackground);
        gc.fillRectangle(x, y, width, height);
      }
    }
    gc.setClipping(clipping);
    clipping.dispose();
    region.dispose();
  }
View Full Code Here

    }
    // Fill in background
    boolean bkSelected = single && selectedIndex != -1;
    drawBackground(gc, shape, bkSelected);
    // Fill in parent background for non-rectangular shape
    Region r = new Region();
    r.add(new Rectangle(x, y, width + 1, height + 1));
    r.subtract(shape);
    gc.setBackground(getParent().getBackground());
    fillRegion(gc, r);
    r.dispose();
   
    // Draw the unselected tabs.
    if (!single) {
      for (int i=0; i < items.length; i++) {
        if (i != selectedIndex && event.getBounds().intersects(items[i].getBounds())) {
View Full Code Here

  public   Color  color;
  public   String  shapeId;
 
  public RecognizedShape()
  {
    polygon = new Region();
  }
View Full Code Here

      for (int i=0; i<points.length; i+=2)
      {
        points[i= xp[i/2];
        points[i+1= yp[i/2];
      }
      polygon = new Region();
      polygon.add( points );
    }
  }
View Full Code Here

  public   Color  color;
  public   String  shapeId;
 
  public RecognizedShape()
  {
    polygon = new Region();
  }
View Full Code Here

      for (int i=0; i<points.length; i+=2)
      {
        points[i= xp[i/2];
        points[i+1= yp[i/2];
      }
      polygon = new Region();
      polygon.add( points );
    }
  }
View Full Code Here

    display = theShell.getDisplay();
        Color color = display.getSystemColor(SWT.COLOR_WIDGET_FOREGROUND);
        theShell.setBackground(color);

        // Ensure that the background won't show on the initial display
        shellRegion = new Region(display);
        theShell.setRegion(shellRegion);
  }
View Full Code Here

  }
 
  public void renderStep(double amount) {
    if (shellRegion != null) {
          shellRegion.dispose();
          shellRegion = new Region(display);
        }

    // Iterate across the set of start/end rects
        Iterator startIter = startRects.iterator();
        Iterator endIter = endRects.iterator();
View Full Code Here

TOP

Related Classes of org.eclipse.swt.graphics.Region

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.