org.eclipse.swt.graphics
Interface Drawable

All Known Implementing Classes:
Control, Widget

public interface Drawable


Method Summary
 void drawLine(int x1, int y1, int x2, int y2)
          Draws a line, using the foreground color, between the points (x1, y1) and (x2, y2).
 void drawRect(int x, int y, int w, int h, boolean drawfill)
          Draws or fills a rectangle specified by the arguments.
 void drawText(String string, int x, int y, int flags)
          Draws the given string, using the receiver's current font and foreground color.
 void setColor(int id, boolean fgbg)
          Sets the receiver's foreground/background color to the system color specified by the argument, or to the default system color for the control if the argument is -1.
 

Method Detail

drawLine

public void drawLine(int x1,
                     int y1,
                     int x2,
                     int y2)
Draws a line, using the foreground color, between the points (x1, y1) and (x2, y2).

Parameters:
x1 - the first point's x coordinate
y1 - the first point's y coordinate
x2 - the second point's x coordinate
y2 - the second point's y coordinate

drawRect

public void drawRect(int x,
                     int y,
                     int w,
                     int h,
                     boolean drawfill)
Draws or fills a rectangle specified by the arguments. Color used is the receivers foreground color, or the background color if the rectangle is filled.

Parameters:
x - the x coordinate of the rectangle to be filled
y - the y coordinate of the rectangle to be filled
w - the width of the rectangle to be filled
h - the height of the rectangle to be filled
drawfill - false=draw, true=fill

drawText

public void drawText(String string,
                     int x,
                     int y,
                     int flags)
Draws the given string, using the receiver's current font and foreground color. Tab expansion, line delimiter and mnemonic processing are performed according to the specified flags. If flags includes DRAW_TRANSPARENT, then the background of the rectangular area where the text is being drawn will not be modified, otherwise it will be filled with the receiver's background color.

The parameter flags may be a combination of:

SWT.DRAW_DELIMITER
draw multiple lines
SWT.DRAW_TAB
expand tabs
SWT.DRAW_MNEMONIC
underline the mnemonic character
SWT.DRAW_TRANSPARENT
transparent background

Parameters:
string - the string to be drawn
x - the x coordinate of the top left corner of the rectangular area where the text is to be drawn
y - the y coordinate of the top left corner of the rectangular area where the text is to be drawn
flags - the flags specifing how to process the text
Throws:
IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the string is null
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed

setColor

public void setColor(int id,
                     boolean fgbg)
Sets the receiver's foreground/background color to the system color specified by the argument, or to the default system color for the control if the argument is -1.

Parameters:
id - the new system color value (or -1)
fgbg - if true/false=set foreground/background color