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

The following examples show how to use org.eclipse.swt.graphics.GC#drawFocus() . 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: DefaultFocusRenderer.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
/** 
 * {@inheritDoc}
 */
public void paint(GC gc, Object value)
{
    GridItem item = (GridItem)value;

    if (item.getParent().isSelected(item))
    {
        gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION));
        gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT));
    }
    else
    {
        gc.setBackground(item.getBackground());
        gc.setForeground(item.getForeground());
    }

    gc.drawFocus(getBounds().x, getBounds().y, getBounds().width + 1, getBounds().height + 1);

}
 
Example 2
Source File: DefaultFocusRenderer.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
/** 
 * {@inheritDoc}
 */
public void paint(GC gc, Object value)
{
    GridItem item = (GridItem)value;

    if (item.getParent().isSelected(item))
    {
        gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION));
        gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT));
    }
    else
    {
        gc.setBackground(item.getBackground());
        gc.setForeground(item.getForeground());
    }

    gc.drawFocus(getBounds().x, getBounds().y, getBounds().width + 1, getBounds().height + 1);

}
 
Example 3
Source File: DefaultFocusRenderer.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
/** 
 * {@inheritDoc}
 */
public void paint(GC gc, Object value)
{
    GridItem item = (GridItem)value;

    if (item.getParent().isSelected(item))
    {
        gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION));
        gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT));
    }
    else
    {
        gc.setBackground(item.getBackground());
        gc.setForeground(item.getForeground());
    }

    gc.drawFocus(getBounds().x, getBounds().y, getBounds().width + 1, getBounds().height + 1);

}
 
Example 4
Source File: TwisteToggleRenderer.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);

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

    if (!isHover())
    {
        gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
    }
    else
    {
        gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_LIST_SELECTION));
    }

    gc.setBackground(gc.getForeground());
    if (isExpanded())
    {
        gc.drawPolygon(new int[] {1, 3, 4, 6, 5, 6, 8, 3 });
        gc.fillPolygon(new int[] {1, 3, 4, 6, 5, 6, 8, 3 });
    }
    else
    {
        gc.drawPolygon(new int[] {3, 1, 6, 4, 6, 5, 3, 8 });
        gc.fillPolygon(new int[] {3, 1, 6, 4, 6, 5, 3, 8 });
    }

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

    gc.setTransform(null);
    transform.dispose();
}
 
Example 5
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 6
Source File: TreeNodeToggleRenderer.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);

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

    gc.setBackground(gc.getDevice().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
    gc.fillRectangle(0, 0, 8, 8);

    gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_WIDGET_FOREGROUND));
    gc.drawLine(2, 4, 6, 4);
    if (!isExpanded())
    {
        gc.drawLine(4, 2, 4, 6);
    }
    gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
    gc.drawRectangle(0, 0, 8, 8);

    if (isFocus())
    {
        gc.setBackground(back);
        gc.setForeground(fore);
        gc.drawFocus(-1, -1, 11, 11);
    }

    gc.setTransform(null);
    transform.dispose();
}
 
Example 7
Source File: ToggleRenderer.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
private void paintMacTwistie(GC gc) {
	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()) {
		gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
	} else {
		gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_LIST_SELECTION));
	}

	gc.setBackground(gc.getForeground());
	if (isExpanded()) {
		gc.drawPolygon(new int[] { 1, 3, 4, 6, 5, 6, 8, 3 });
		gc.fillPolygon(new int[] { 1, 3, 4, 6, 5, 6, 8, 3 });
	} else {
		gc.drawPolygon(new int[] { 3, 1, 6, 4, 6, 5, 3, 8 });
		gc.fillPolygon(new int[] { 3, 1, 6, 4, 6, 5, 3, 8 });
	}

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

	gc.setTransform(null);
	transform.dispose();
}
 
Example 8
Source File: CellRendererBase.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
     * Draw focus marking. Should be called with the corrected drawing area.
     * 
     * @param gc GC
     * @param drawingArea corrected drawing area
     */
    protected void drawFocus(GC gc, Rectangle drawingArea) {
        Color bg = gc.getBackground();
        Color fg = gc.getForeground();
        gc.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK));
        gc.drawFocus(drawingArea.x + FOCUSINSETS, drawingArea.y + FOCUSINSETS, drawingArea.width - 2 * FOCUSINSETS,
                drawingArea.height - 2 * FOCUSINSETS - 1);
// gc.drawRectangle(drawingArea.x + 2, drawingArea.y + 2, drawingArea.width - 4, drawingArea.height - 3);
        gc.setForeground(fg);
        gc.setBackground(bg);
    }
 
Example 9
Source File: CellRendererBase.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
     * Draw focus marking. Should be called with the corrected drawing area.
     * 
     * @param gc GC
     * @param drawingArea corrected drawing area
     */
    protected void drawFocus(GC gc, Rectangle drawingArea) {
        Color bg = gc.getBackground();
        Color fg = gc.getForeground();
        gc.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK));
        gc.drawFocus(drawingArea.x + FOCUSINSETS, drawingArea.y + FOCUSINSETS, drawingArea.width - 2 * FOCUSINSETS,
                drawingArea.height - 2 * FOCUSINSETS - 1);
// gc.drawRectangle(drawingArea.x + 2, drawingArea.y + 2, drawingArea.width - 4, drawingArea.height - 3);
        gc.setForeground(fg);
        gc.setBackground(bg);
    }