Java Code Examples for org.eclipse.swt.graphics.GC#drawRoundRectangle()

The following examples show how to use org.eclipse.swt.graphics.GC#drawRoundRectangle() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RangeSlider.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Draw the background
 *
 * @param gc graphic context
 */
private void drawBackgroundHorizontal(final GC gc) {
	final Rectangle clientArea = getClientArea();

	gc.setBackground(getBackground());
	gc.fillRectangle(clientArea);

	if (isEnabled()) {
		gc.setForeground(getForeground());
	} else {
		gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_GRAY));
	}
	gc.drawRoundRectangle(9, 9, clientArea.width - 20, clientArea.height - 20, 3, 3);

	final float pixelSize = computePixelSizeForHorizontalSlider();
	final int startX = (int) (pixelSize * lowerValue);
	final int endX = (int) (pixelSize * upperValue);
	if (isEnabled()) {
		gc.setBackground(getForeground());
	} else {
		gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_GRAY));
	}
	gc.fillRectangle(12 + startX, 9, endX - startX - 6, clientArea.height - 20);

}
 
Example 2
Source File: JobGraph.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
protected void drawRect( GC gc, Rectangle rect ) {
  if ( rect == null ) {
    return;
  }

  gc.setLineStyle( SWT.LINE_DASHDOT );
  gc.setLineWidth( 1 );
  gc.setForeground( GUIResource.getInstance().getColorDarkGray() );
  // PDI-2619: SWT on Windows doesn't cater for negative rect.width/height so handle here.
  Point s = new Point( rect.x + offset.x, rect.y + offset.y );
  if ( rect.width < 0 ) {
    s.x = s.x + rect.width;
  }
  if ( rect.height < 0 ) {
    s.y = s.y + rect.height;
  }
  gc.drawRoundRectangle( s.x, s.y, Math.abs( rect.width ), Math.abs( rect.height ), 3, 3 );
  gc.setLineStyle( SWT.LINE_SOLID );
}
 
Example 3
Source File: Chips.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
private void drawWidgetBorder(final GC gc) {
	final Rectangle rect = getClientArea();
	Color color = borderColor;
	if (cursorInside) {
		color = hoverBorderColor;
	} else if (isPush && selection) {
		color = pushedStateBorderColor;
	}

	if (color == null) {
		// No border
		return;
	}

	gc.setForeground(color);
	gc.drawRoundRectangle(0, 0, rect.width - 2, rect.height - 2, rect.height, rect.height);

}
 
Example 4
Source File: RangeSlider.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Draws the background
 *
 * @param gc graphic context
 */
private void drawBackgroundVertical(final GC gc) {
	final Rectangle clientArea = getClientArea();
	gc.setBackground(getBackground());
	gc.fillRectangle(clientArea);

	if (isEnabled()) {
		gc.setForeground(getForeground());
	} else {
		gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_GRAY));
	}
	gc.drawRoundRectangle(9, 9, clientArea.width - 20, clientArea.height - 20, 3, 3);

	final float pixelSize = computePixelSizeForVerticalSlider();
	final int startY = (int) (pixelSize * lowerValue);
	final int endY = (int) (pixelSize * upperValue);
	if (isEnabled()) {
		gc.setBackground(getForeground());
	} else {
		gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_GRAY));
	}
	gc.fillRectangle(9, 12 + startY, clientArea.width - 20, endY - startY - 6);

}
 
Example 5
Source File: NebulaSlider.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
private void drawBar(GC gc) {
	final Rectangle rect = getClientArea();
	gc.setForeground(barBorderColor);
	gc.setBackground(barInsideColor);

	final int x = H_MARGIN + SELECTOR_WIDTH / 2;
	final int y = (rect.height - BAR_HEIGHT) / 2;
	final int width = rect.width - H_MARGIN * 2 - SELECTOR_WIDTH;

	gc.fillRoundRectangle(x, y, width, BAR_HEIGHT, BAR_HEIGHT, BAR_HEIGHT);
	gc.drawRoundRectangle(x, y, width, BAR_HEIGHT, BAR_HEIGHT, BAR_HEIGHT);
}
 
Example 6
Source File: NebulaSlider.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
private void drawSelectionPart(GC gc) {
	final Rectangle rect = getClientArea();
	gc.setForeground(barBorderColor);
	gc.setBackground(barSelectionColor);

	final int x = H_MARGIN + SELECTOR_WIDTH / 2;
	final int y = (rect.height - BAR_HEIGHT) / 2;

	gc.fillRoundRectangle(x, y, xPosition, BAR_HEIGHT, BAR_HEIGHT, BAR_HEIGHT);
	gc.drawRoundRectangle(x, y, xPosition, BAR_HEIGHT, BAR_HEIGHT, BAR_HEIGHT);
}
 
Example 7
Source File: NebulaSlider.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
private void drawSelector(GC gc) {
	final Rectangle rect = getClientArea();
	gc.setForeground(selectorColorBorder);
	gc.setBackground(selectorColor);

	final int y = (rect.height - SELECTOR_HEIGHT) / 2;

	// Draw the body
	gc.fillRoundRectangle(H_MARGIN + xPosition, y, SELECTOR_WIDTH, SELECTOR_HEIGHT, SELECTOR_HEIGHT, SELECTOR_HEIGHT);
	gc.drawRoundRectangle(H_MARGIN + xPosition, y, SELECTOR_WIDTH, SELECTOR_HEIGHT, SELECTOR_HEIGHT, SELECTOR_HEIGHT);

	// Draw the arrows
	gc.setForeground(arrowColor);
	gc.setLineWidth(3);
	final int baseY = y + SELECTOR_HEIGHT / 2;
	gc.drawLine(H_MARGIN + xPosition + 10, baseY, H_MARGIN + xPosition + 17, baseY - 7);
	gc.drawLine(H_MARGIN + xPosition + 10, baseY, H_MARGIN + xPosition + 17, baseY + 7);

	gc.drawLine(H_MARGIN + xPosition + SELECTOR_WIDTH - 10, baseY, H_MARGIN + xPosition + SELECTOR_WIDTH - 17, baseY - 7);
	gc.drawLine(H_MARGIN + xPosition + SELECTOR_WIDTH - 10, baseY, H_MARGIN + xPosition + SELECTOR_WIDTH - 17, baseY + 7);

	// And the value
	gc.setForeground(selectorTextColor);
	gc.setFont(textFont);
	final String valueAsString = String.valueOf(value);
	final Point textSize = gc.textExtent(valueAsString);

	final int xText = H_MARGIN + xPosition + SELECTOR_WIDTH / 2;
	gc.drawText(valueAsString, xText - textSize.x / 2, y + 2, true);
}
 
Example 8
Source File: ChoiceWidget.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Draw the composite
 */
private void drawComposite() {

	final Rectangle rect = getClientArea();
	final Image newImage = new Image(getDisplay(), Math.max(1, rect.width), Math.max(1, rect.height));

	final GC gc = new GC(newImage);

	final boolean inside = insideComposite || insideImage || insideInstruction || insideText;

	if (!inside && !selection) {
		gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_WHITE));
		gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WHITE));
		gc.drawRectangle(rect.x, rect.y, rect.width, rect.height);
	} else {
		// The mouse is over OR the item is selected
		final Color gradientColor = inside ? new Color(getDisplay(), 220, 231, 243) : new Color(getDisplay(), 241, 241, 241);
		final Color borderColor = inside ? new Color(getDisplay(), 35, 107, 178) : new Color(getDisplay(), 192, 192, 192);

		gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WHITE));
		gc.setBackground(gradientColor);
		gc.fillGradientRectangle(rect.x, rect.y, rect.width, rect.height, true);

		gc.setForeground(borderColor);
		gc.drawRoundRectangle(rect.x, rect.y, rect.width - 1, rect.height - 1, 2, 2);

		gradientColor.dispose();
		borderColor.dispose();
	}
	gc.dispose();

	setBackgroundImage(newImage);
	if (oldImage != null) {
		oldImage.dispose();
	}
	oldImage = newImage;
}
 
Example 9
Source File: CheckBoxGroup.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Draws the widget
 */
private void drawWidget(final GC gc) {
	final Rectangle rect = getClientArea();
	final int margin = (int) (button.getSize().y * 1.5);
	final int startY = margin / 2;

	gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
	gc.drawRoundRectangle(1, startY, rect.width - 2, rect.height - startY - 2, 2, 2);

	gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));
	gc.drawRoundRectangle(2, startY + 1, rect.width - 4, rect.height - startY - 4, 2, 2);
}
 
Example 10
Source File: RoundedToolbar.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
private void drawBorders(final GC gc, final int width, final int height) {
	final AdvancedPath path = new AdvancedPath(getDisplay());
	path.addRoundRectangle(0, 0, width, height, cornerRadius, cornerRadius);
	gc.setClipping(path);

	gc.setForeground(START_GRADIENT_COLOR);
	gc.setBackground(END_GRADIENT_COLOR);
	gc.fillGradientRectangle(0, 0, width, height, true);

	gc.setForeground(BORDER_COLOR);
	gc.drawRoundRectangle(0, 0, width - 1, height - 1, cornerRadius, cornerRadius);

	gc.setClipping((Rectangle) null);
}
 
Example 11
Source File: MinMaxToggleRenderer.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
public void paint(GC gc, Object value)
{

    Transform transform = new Transform(gc.getDevice());
    transform.translate(getBounds().x, getBounds().y);
    gc.setTransform(transform);

    gc.setBackground(gc.getDevice().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
    gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));

    if (isHover())
    {
        gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
        gc.drawRoundRectangle(0, 0, 17, 17, 5, 5);
    }

    gc.setBackground(gc.getDevice().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
    gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));

    if (isExpanded())
    {
        gc.fillRectangle(4, 3, 9, 3);
        gc.drawRectangle(4, 3, 9, 3);
    }
    else
    {
        gc.fillRectangle(4, 3, 9, 9);
        gc.drawRectangle(4, 3, 9, 9);
        gc.drawLine(4, 5, 13, 5);
    }

    gc.setTransform(null);
    transform.dispose();

}
 
Example 12
Source File: SComposite.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
private void paintControl(GC gc) {
	if((borderStyle & BORDER) != 0) {
		if(advancedGraphics) {
			gc.setAntialias(SWT.ON);
		}

		gc.setLineWidth(borderWidth);

		Rectangle r = getClientArea();

		if((borderStyle & SQUARE) != 0) {
			if((borderStyle & FLAT) == 0) {
				gc.setForeground(WHITE);
				gc.drawLine(r.x+1,r.y+1, r.x+1,r.y+r.height-3);
				gc.drawLine(r.x+1,r.y+1, r.x+r.width-3,r.y+1);
			}
			gc.setForeground(borderColor);
			gc.drawRectangle(r.x,r.y, r.width-1,r.height-1);
		} else {
			if((borderStyle & FLAT) == 0) {
				gc.setForeground(WHITE);
				gc.drawLine(r.x+1,r.y+1, r.x+1,r.y+r.height-3);
				gc.drawLine(r.x+1,r.y+1, r.x+r.width-3,r.y+1);
			}
			gc.setForeground(borderColor);
			gc.drawRoundRectangle(r.x+(borderWidth/2),r.y+(borderWidth/2), r.width-borderWidth,r.height-borderWidth, borderWidth*5, borderWidth*5);
		}
	}
}
 
Example 13
Source File: Histogram.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Draw a time range window
 *
 * @param imageGC
 *            the GC
 * @param rangeStartTime
 *            the range start time
 * @param rangeDuration
 *            the range duration
 */
protected void drawTimeRangeWindow(GC imageGC, long rangeStartTime, long rangeDuration) {

    if (fScaledData == null) {
        return;
    }

    // Map times to histogram coordinates
    double bucketSpan = fScaledData.fBucketDuration;
    long startTime = Math.min(rangeStartTime, rangeStartTime + rangeDuration);
    double rangeWidth = (Math.abs(rangeDuration) / bucketSpan);

    int left = (int) ((startTime - fDataModel.getFirstBucketTime()) / bucketSpan);
    int right = (int) (left + rangeWidth);
    int center = (left + right) / 2;
    int height = fCanvas.getSize().y;
    int arc = Math.min(15, (int) rangeWidth);

    // Draw the selection window
    imageGC.setForeground(fTimeRangeColor);
    imageGC.setLineWidth(1);
    imageGC.setLineStyle(SWT.LINE_SOLID);
    imageGC.drawRoundRectangle(left, 0, (int) rangeWidth, height - 1, arc, arc);

    // Fill the selection window
    imageGC.setBackground(fTimeRangeColor);
    imageGC.setAlpha(35);
    imageGC.fillRoundRectangle(left + 1, 1, (int) rangeWidth - 1, height - 2, arc, arc);
    imageGC.setAlpha(255);

    // Draw the cross hair
    imageGC.setForeground(fTimeRangeColor);
    imageGC.setLineWidth(1);
    imageGC.setLineStyle(SWT.LINE_SOLID);

    int chHalfWidth = ((rangeWidth < 60) ? (int) ((rangeWidth * 2) / 3) : 40) / 2;
    imageGC.drawLine(center - chHalfWidth, height / 2, center + chHalfWidth, height / 2);
    imageGC.drawLine(center, (height / 2) - chHalfWidth, center, (height / 2) + chHalfWidth);
}
 
Example 14
Source File: BoxDecoratorImpl.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
void drawRectangle(final GC gc, final int x, final int y, final int width, final int height) {
	if (settings.getRoundBox()) {
		gc.drawRoundRectangle(x, y, width, height, ROUND_BOX_ARC, ROUND_BOX_ARC);
	} else {
		gc.drawRectangle(x, y, width, height);
	}
}
 
Example 15
Source File: PaintUtils.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
public static void drawRoundedBorder(GC gc, Rectangle bounds, Color borderColor) {
  Color backupBackground = gc.getBackground();
  int backupLineWidth = gc.getLineWidth();

  gc.setLineWidth(LINE_WEIGHT);
  gc.setForeground(borderColor);
  gc.drawRoundRectangle(
      bounds.x, bounds.y, bounds.width - LINE_WEIGHT, bounds.height - LINE_WEIGHT, ARC, ARC);

  gc.setBackground(backupBackground);
  gc.setLineWidth(backupLineWidth);
}
 
Example 16
Source File: ChevronsToggleRenderer.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/** 
 * @see org.eclipse.nebula.widgets.pgroup.AbstractRenderer#paint(org.eclipse.swt.graphics.GC, java.lang.Object)
 */
public void paint(GC gc, Object value)
{
    Transform transform = new Transform(gc.getDevice());
    transform.translate(getBounds().x, getBounds().y);
    gc.setTransform(transform);

    Color back = gc.getBackground();
    Color fore = gc.getForeground();

    if (isHover())
    {
        Color old = gc.getForeground();
        gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
        gc.drawRoundRectangle(0, 0, 16, 15, 5, 5);
        gc.setForeground(old);
    }

    if (isExpanded())
    {
        gc.drawPolygon(new int[] {5, 6, 8, 3, 11, 6, 10, 6, 8, 4, 6, 6 });
        gc.drawPolygon(new int[] {5, 10, 8, 7, 11, 10, 10, 10, 8, 8, 6, 10 });
    }
    else
    {
        gc.drawPolygon(new int[] {5, 4, 8, 7, 11, 4, 10, 4, 8, 6, 6, 4 });
        gc.drawPolygon(new int[] {5, 8, 8, 11, 11, 8, 10, 8, 8, 10, 6, 8 });
    }

    if (isFocus())
    {
        gc.setBackground(back);
        gc.setForeground(fore);
        gc.drawFocus(2, 2, 13, 12);
    }

    gc.setTransform(null);
    transform.dispose();

}
 
Example 17
Source File: NavigationPageGraphics.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
private void onPaint(GC gc) {
	gc.setAdvanced(true);
	if (gc.getAdvanced())
		gc.setTextAntialias(SWT.ON);
	if (items == null) {
		return;
	}
	computeBoundsIfNeeded(gc);

	Color fg = getDisplay().getSystemColor(SWT.COLOR_WIDGET_FOREGROUND);
	Color bg = getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);

	boolean separator = false;
	int x, y, width, height = 0;
	boolean selected = false;
	boolean enabled = false;

	for (NavigationPageGraphicsItem pageItem : items) {
		selected = pageItem.equals(selectedItem);
		enabled = pageItem.isEnabled();
		separator = pageItem.isSeparator();

		x = pageItem.getBounds().x;
		y = pageItem.getBounds().y;
		width = pageItem.getBounds().width;
		height = pageItem.getBounds().height;

		// Fill rectangle
		Color filledRectangleColor = getFilledRectangleColor(selected,
				!separator ? enabled : true, bg);
		if (filledRectangleColor != null) {
			gc.setBackground(filledRectangleColor);
			if (round != null) {
				gc.fillRoundRectangle(x, y, width, height, round, round);
			} else {
				gc.fillRectangle(x, y, width, height);
			}
		}

		// Border rectangle
		if (!separator) {
			Color borderRectangleColor = getBorderRectangleColor(selected,
					enabled, bg);
			if (borderRectangleColor != null) {
				gc.setForeground(borderRectangleColor);
				if (round != null) {
					gc.drawRoundRectangle(x, y, width, height, round, round);
				} else {
					gc.drawRectangle(x, y, width, height);
				}
			}
		}

		// Foreground text
		Color textColor = getTextColor(selected, enabled);
		if (textColor != null) {
			gc.setForeground(textColor);
		} else {
			gc.setForeground(fg);
		}
		gc.drawString(pageItem.getText(), x + 3, y, true);
	}
}
 
Example 18
Source File: TimeGraphControl.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Draw many items at once
 *
 * @param bounds
 *            The bounds of the control
 * @param timeProvider
 *            The time provider
 * @param items
 *            The array items to draw
 * @param topIndex
 *            The index of the first element to draw
 * @param nameSpace
 *            The name space width
 * @param gc
 *            Graphics context
 */
public void drawItems(Rectangle bounds, ITimeDataProvider timeProvider,
        Item[] items, int topIndex, int nameSpace, GC gc) {
    int bottomIndex = Integer.min(topIndex + countPerPage() + 1, items.length);
    for (int i = topIndex; i < bottomIndex; i++) {
        Item item = items[i];
        drawItem(item, bounds, timeProvider, i, nameSpace, gc);
    }
    TraceCompassLogUtils.traceCounter(LOGGER, Level.FINER, fDrawItemsCountLabel, bottomIndex - topIndex);

    if (gc == null) {
        return;
    }

    /*
     * Draw entries, entries contain events
     */
    for (DeferredEntry entry : fPostDrawEntries) {
        entry.draw(fTimeGraphProvider, gc);
    }

    // Defer line drawing
    for (DeferredLine line : fLines) {
        line.draw(fTimeGraphProvider, gc);
    }

    Color prev = gc.getForeground();
    Color black = TimeGraphRender.getColor(BLACK.toInt());
    gc.setForeground(black);
    int prevAA = gc.getAntialias();
    /*
     * BUG: Doesn't work in certain distros of Linux the end result is
     * anti-aliased points. They may actually look better but are not as
     * accurate.
     */
    gc.setAntialias(SWT.OFF);
    int prevLineWidth = gc.getLineWidth();
    gc.setLineWidth(1);
    // Deferred point drawing, they are aggregated into segments
    for (DeferredSegment seg : fPoints) {
        seg.draw(fTimeGraphProvider, gc);
    }
    gc.setLineWidth(prevLineWidth);
    gc.setAntialias(prevAA);
    // Draw selection at very end
    for (Rectangle rectangle : fSelectedRectangles) {
        int arc = Math.min(rectangle.height + 1, rectangle.width) / 2;
        gc.drawRoundRectangle(rectangle.x - 1, rectangle.y - 1, rectangle.width, rectangle.height + 1, arc, arc);
    }
    gc.setForeground(prev);
}
 
Example 19
Source File: TimeGraphRender.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
@Override
protected void drawBorder(GC gc) {
    Rectangle bounds = getBounds();
    gc.drawRoundRectangle(bounds.x, bounds.y, bounds.width, bounds.height, fArc, fArc);
}
 
Example 20
Source File: NButton.java    From ldparteditor with MIT License 4 votes vote down vote up
private void paint(PaintEvent event) {
    final GC gc = event.gc;
    final Image img = this.img;
    final boolean focused = this.isFocusControl();
    final boolean enabled = this.isEnabled();
    final boolean hasImage = img != null;
    final int img_width = hasImage ? img.getImageData().width : 0;
    final int img_height = hasImage ? img.getImageData().height : 0;
    final int this_width = getBounds().width - 1;

    gc.setFont(Font.SYSTEM);
    // setFont before using textExtent, so that the size of the text
    // can be calculated correctly
    final Point textExtent = getText().isEmpty() ? new Point(0,0) : gc.textExtent(getText());

    // TODO 1. Calculate sizes


    // TODO 2. Draw Content

    if (selected && (canToggle || isRadio)) {
        gc.setBackground(SWTResourceManager.getColor(160, 160, 200));
        gc.fillRoundRectangle(0, 0, Math.max(img_width + 9 + textExtent.x, this_width), Math.max(textExtent.y, img_height) + 9, 5, 5);
        gc.setBackground(getBackground());
    }

    gc.setForeground(SWTResourceManager.getColor(255, 255, 255));

    if (hovered || focused) {
        gc.setForeground(SWTResourceManager.getColor(0, 0, 0));
    }
    if (pressed) {
        gc.setForeground(SWTResourceManager.getColor(220, 220, 220));
    }



    if (!canCheck && !hasBorder) {

        if (!enabled) {
            gc.setForeground(SWTResourceManager.getColor(200, 200, 200));
        }
        gc.drawRoundRectangle(0, 0, Math.max(img_width + 9 + textExtent.x, this_width), Math.max(textExtent.y, img_height) + 9, 5, 5);

        gc.setForeground(SWTResourceManager.getColor(60, 60, 60));

        if (hovered || focused) {
            gc.setBackground(SWTResourceManager.getColor(160, 160, 200));
            gc.fillRoundRectangle(1, 1, Math.max(img_width + 9 + textExtent.x, this_width) - 1, Math.max(textExtent.y, img_height) + 9 - 1, 5, 5);
            if (selected && (canToggle || isRadio)) {
                gc.setBackground(SWTResourceManager.getColor(160, 160, 200));
            } else {
                gc.setBackground(getBackground());
            }
            gc.fillRoundRectangle(2, 2, Math.max(img_width + 9 + textExtent.x, this_width) - 3, Math.max(textExtent.y, img_height) + 9 - 3, 5, 5);

        }
        if (pressed) {
            gc.setForeground(SWTResourceManager.getColor(30, 30, 30));
        }
        if (!enabled) {
            gc.setForeground(SWTResourceManager.getColor(200, 200, 200));
        }
        gc.drawRoundRectangle(1, 1, Math.max(img_width + 9 + textExtent.x, this_width) - 1, Math.max(textExtent.y, img_height) + 9 - 1, 5, 5);
    }

    if (hasImage) {

        gc.drawImage(img, 5, 5);
    }

    gc.setForeground(getForeground());

    gc.drawString(getText(), img_width + 5, 5, true);


    // 3. Paint custom forms
    for (PaintListener pl : painters) {
        pl.paintControl(event);
    }
}