Color

Instances of this class manage the operating system resources that implement SWT's RGB color model. To create a color you can either specify the individual color components as integers in the range 0 to 255 or provide an instance of an <code>RGB</code>. <p> Application code must explicitly invoke the <code>Color.dispose()</code> method to release the operating system resources managed by each instance when those instances are no longer required. </p>

@see RGB @see Device#getSystemColor @see <a href="http://www.eclipse.org/swt/snippets/#color">Color and RGB snippets</a> @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: PaintExample</a> @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>

Constructors

this
this(Device device, int red, int green, int blue)

Constructs a new instance of this class given a device and the desired red, green and blue values expressed as ints in the range 0 to 255 (where 0 is black and 255 is full brightness). On limited color devices, the color instance created by this call may not have the same RGB values as the ones specified by the arguments. The RGB values on the returned instance will be the color values of the operating system color. <p> You must dispose the color when it is no longer required. </p>

this
this(Device device, in RGB rgb)

Constructs a new instance of this class given a device and an <code>RGB</code> describing the desired red, green and blue values. On limited color devices, the color instance created by this call may not have the same RGB values as the ones specified by the argument. The RGB values on the returned instance will be the color values of the operating system color. <p> You must dispose the color when it is no longer required. </p>

Members

Functions

getBlue
int getBlue()

Returns the amount of blue in the color, from 0 to 255.

getGreen
int getGreen()

Returns the amount of green in the color, from 0 to 255.

getRGB
RGB getRGB()

Returns an <code>RGB</code> representing the receiver.

getRed
int getRed()

Returns the amount of red in the color, from 0 to 255.

isDisposed
bool isDisposed()

Returns <code>true</code> if the color has been disposed, and <code>false</code> otherwise. <p> This method gets the dispose state for the color. When a color has been disposed, it is an error to invoke any other method using the color.

opEquals
equals_t opEquals(Object object)

Compares the argument to the receiver, and returns true if they represent the <em>same</em> object using a class specific comparison.

toHash
hash_t toHash()

Returns an integer hash code for the receiver. Any two objects that return <code>true</code> when passed to <code>equals</code> must return the same value for this method.

toString
String toString()

Returns a string containing a concise, human-readable description of the receiver.

Static functions

gtk_new
Color gtk_new(Device device, GdkColor* gdkColor)

Invokes platform specific functionality to allocate a new color. <p> <b>IMPORTANT:</b> This method is <em>not</em> part of the public API for <code>Color</code>. It is marked public only so that it can be shared within the packages provided by SWT. It is not available on all platforms, and should never be called from application code. </p>

Variables

handle
GdkColor* handle;

the handle to the OS color resource (Warning: This field is platform dependent) <p> <b>IMPORTANT:</b> This field is <em>not</em> part of the SWT public API. It is marked public only so that it can be shared within the packages provided by SWT. It is not available on all platforms and should never be accessed from application code. </p>

Inherited Members

From Resource

device
Device device;

the device where this resource was created

dispose
void dispose()

Disposes of the operating system resources associated with this resource. Applications must dispose of all resources which they allocate.

getDevice
Device getDevice()

Returns the <code>Device</code> where this resource was created.

isDisposed
bool isDisposed()

Returns <code>true</code> if the resource has been disposed, and <code>false</code> otherwise. <p> This method gets the dispose state for the resource. When a resource has been disposed, it is an error to invoke any other method using the resource.

Meta