Example usage for org.eclipse.swt.graphics Color isDisposed

List of usage examples for org.eclipse.swt.graphics Color isDisposed

Introduction

In this page you can find the example usage for org.eclipse.swt.graphics Color isDisposed.

Prototype

public boolean isDisposed() 

Source Link

Usage

From source file:cookxml.cookswt.util.SwtUtils.java

/**
 * Dispose a color if it is not a system color.
 *
 * @param   color The color to be disposed.
 * @param   device The device that contains the color.
 *///from ww w .  ja v  a  2 s.c  o m
public static void disposeColor(Color color, Device device) {
    if (color.isDisposed())
        return;
    if (!isSystemColor(color, device)) {
        assert disposeDebug("Dispose color: " + color);
        color.dispose();
    }
}

From source file:org.eclipse.swt.examples.accessibility.CTableItem.java

/**
 * Sets the receiver's background color to the color specified
 * by the argument, or to the default system color for the item
 * if the argument is null./*from  w  w  w  . jav  a2 s . co m*/
 *
 * @param color the new color (or null)
 *
 * @exception IllegalArgumentException <ul>
 *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
 * </ul>
 * @exception SWTException <ul>
 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
 * </ul>
 *
 * @since 2.0
 */
public void setBackground(Color color) {
    checkWidget();
    if (color != null && color.isDisposed()) {
        SWT.error(SWT.ERROR_INVALID_ARGUMENT);
    }
    Color oldColor = background;
    if (oldColor == color)
        return;
    background = color;
    if (oldColor != null && oldColor.equals(color))
        return;
    if ((parent.getStyle() & SWT.VIRTUAL) != 0)
        cached = true;
    redrawItem();
}

From source file:org.eclipse.swt.examples.accessibility.CTableItem.java

/**
 * Sets the receiver's foreground color to the color specified
 * by the argument, or to the default system color for the item
 * if the argument is null.//  w w w. j av  a  2s.  c  om
 *
 * @param color the new color (or null)
 *
 * @exception IllegalArgumentException <ul>
 *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
 * </ul>
 * @exception SWTException <ul>
 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
 * </ul>
 *
 * @since 2.0
 */
public void setForeground(Color color) {
    checkWidget();
    if (color != null && color.isDisposed()) {
        SWT.error(SWT.ERROR_INVALID_ARGUMENT);
    }
    Color oldColor = foreground;
    if (oldColor == color)
        return;
    foreground = color;
    if (oldColor != null && oldColor.equals(color))
        return;
    if ((parent.getStyle() & SWT.VIRTUAL) != 0)
        cached = true;
    redrawItem();
}

From source file:org.eclipse.swt.examples.accessibility.CTableItem.java

/**
 * Sets the background color at the given column index in the receiver
 * to the color specified by the argument, or to the default system color for the item
 * if the argument is null.// w  ww. ja va  2s . c  o  m
 *
 * @param index the column index
 * @param color the new color (or null)
 *
 * @exception IllegalArgumentException <ul>
 *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
 * </ul>
 * @exception SWTException <ul>
 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
 * </ul>
 *
 * @since 3.0
 */
public void setBackground(int columnIndex, Color color) {
    checkWidget();
    if (color != null && color.isDisposed()) {
        SWT.error(SWT.ERROR_INVALID_ARGUMENT);
    }
    int validColumnCount = Math.max(1, parent.columns.length);
    if (!(0 <= columnIndex && columnIndex < validColumnCount))
        return;
    if (cellBackgrounds == null) {
        if (color == null)
            return;
        cellBackgrounds = new Color[validColumnCount];
    }
    Color oldColor = cellBackgrounds[columnIndex];
    if (oldColor == color)
        return;
    cellBackgrounds[columnIndex] = color;
    if (oldColor != null && oldColor.equals(color))
        return;
    if ((parent.getStyle() & SWT.VIRTUAL) != 0)
        cached = true;

    if (isInViewport()) {
        Rectangle bounds = getCellBounds(columnIndex);
        parent.redraw(bounds.x, bounds.y, bounds.width, bounds.height, false);
    }
}

From source file:org.eclipse.swt.examples.accessibility.CTableItem.java

/**
 * Sets the foreground color at the given column index in the receiver
 * to the color specified by the argument, or to the default system color for the item
 * if the argument is null./*from  w w w  .j a v a2 s  .  c  o  m*/
 *
 * @param index the column index
 * @param color the new color (or null)
 *
 * @exception IllegalArgumentException <ul>
 *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
 * </ul>
 * @exception SWTException <ul>
 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
 * </ul>
 *
 * @since 3.0
 */
public void setForeground(int columnIndex, Color color) {
    checkWidget();
    if (color != null && color.isDisposed()) {
        SWT.error(SWT.ERROR_INVALID_ARGUMENT);
    }
    int validColumnCount = Math.max(1, parent.columns.length);
    if (!(0 <= columnIndex && columnIndex < validColumnCount))
        return;
    if (cellForegrounds == null) {
        if (color == null)
            return;
        cellForegrounds = new Color[validColumnCount];
    }
    Color oldColor = cellForegrounds[columnIndex];
    if (oldColor == color)
        return;
    cellForegrounds[columnIndex] = color;
    if (oldColor != null && oldColor.equals(color))
        return;
    if ((parent.getStyle() & SWT.VIRTUAL) != 0)
        cached = true;

    if (isInViewport()) {
        redraw(getTextX(columnIndex), parent.getItemY(this), textWidths[columnIndex] + 2 * MARGIN_TEXT,
                parent.itemHeight, columnIndex);
    }
}