Top Description Fields Constructors Methods
org.eclipse.swt.widgets

public Class Canvas

extends Composite
Class Inheritance
Known Direct Subclasses
org.eclipse.swt.widgets.Decorations, org.eclipse.swt.custom.AnimatedProgress, org.eclipse.swt.custom.CLabel, org.eclipse.swt.custom.StyledText, org.eclipse.swt.custom.TableCursor, org.eclipse.swt.custom.TreeCursor, org.eclipse.swt.opengl.GLCanvas
Imports
org.eclipse.swt.*, org.eclipse.swt.graphics.*, org.eclipse.swt.internal.*, org.eclipse.swt.internal.cairo.*, org.eclipse.swt.internal.gtk.*

Instances of this class provide a surface for drawing arbitrary graphics.
Styles:
(none)
Events:
(none)

This class may be subclassed by custom control implementors who are building controls that are not constructed from aggregates of other controls. That is, they are either painted using SWT graphics calls or are handled by native methods.

See Also
Composite, Canvas snippets, SWT Example: ControlExample, Sample code and further information

Field Summary

Modifier and TypeField and Description
pack-priv boolean
pack-priv Caret
pack-priv boolean
pack-priv IME
Inherited from org.eclipse.swt.widgets.Composite:
backgroundModechildrenLoweredembeddedHandlefixClipHandlefixClipMapimHandlelayoutlayoutCountNO_INPUT_METHODnoChildDrawingpopupChildsocketHandletabList

Constructor Summary

AccessConstructor and Description
pack-priv
public
Canvas(Composite
a composite control which will be the parent of the new instance (cannot be null)
parent
,
int
the style of control to construct
style
)

Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.

Method Summary

Modifier and TypeMethod and Description
public void
drawBackground(GC
the gc where the rectangle is to be filled
gc
,
int
the x coordinate of the rectangle to be filled
x
,
int
the y coordinate of the rectangle to be filled
y
,
int
the width of the rectangle to be filled
width
,
int
the height of the rectangle to be filled
height
)

Fills the interior of the rectangle specified by the arguments, with the receiver's background.

private void
drawCaret(long widget, long cairo)

pack-priv void
drawCaretInFocus(long widget, long cairo)

public Caret

Returns:

the caret for the receiver, may be null
getCaret
()

Returns the caret.

pack-priv Point
public IME

Returns:

the IME
getIME
()

Returns the IME.

pack-priv long
pack-priv long
gtk_commit(long imcontext, long text)

Overrides org.eclipse.swt.widgets.Control.gtk_commit.

pack-priv long
gtk_draw(long widget, long cairo)

Overrides org.eclipse.swt.widgets.Composite.gtk_draw.

pack-priv long
pack-priv long
pack-priv long
pack-priv void
redrawWidget(int x, int y, int width, int height, boolean redrawAll, boolean all, boolean trim)

Overrides org.eclipse.swt.widgets.Scrollable.redrawWidget.

pack-priv void
pack-priv void
public void
scroll(int
the x coordinate of the destination
destX
,
int
the y coordinate of the destination
destY
,
int
the x coordinate of the source
x
,
int
the y coordinate of the source
y
,
int
the width of the area
width
,
int
the height of the area
height
,
boolean
trueif children should be scrolled, and false otherwise
all
)

Scrolls a rectangular area of the receiver by first copying the source area to the destination and then causing the area of the source which is not covered by the destination to be repainted.

pack-priv void
scrollInPixels(int destX, int destY, int x, int y, int width, int height, boolean all)

pack-priv int
setBounds(int x, int y, int width, int height, boolean move, boolean resize)

Overrides org.eclipse.swt.widgets.Composite.setBounds.

public void
setCaret(Caret
the new caret for the receiver, may be null
caret
)

Sets the receiver's caret.

public void
setFont(Font
the new font (or null)
font
)

Overrides org.eclipse.swt.widgets.Control.setFont.

Sets the font that the receiver will use to paint textual information to the font specified by the argument, or to the default font for that kind of control if the argument is null.
public void
setIME(IME
the new IME for the receiver, may be null
ime
)

Sets the receiver's IME.

pack-priv void
Inherited from org.eclipse.swt.widgets.Composite:
_getChildren_getTabListadjustChildClippingapplyThemeBackgroundchangedcheckBufferedcheckStylecheckSubclasscheckSubwindowcomputeSizeInPixelscomputeTabListconnectFixedHandleDrawcreateHandlecreateHandlederegisterdrawBackgrounddrawBackgroundInPixelsenableWidgetfindDeferredControlfindMenusfixChildrenfixClippingsfixModalfixParentGdkResourcefixStylefixTabListfixZOrderfocusHandleforceFocusgetBackgroundModegetChildrengetChildrenCountgetClientAreaInPixelsgetLayoutgetLayoutDeferredgetTabListgtk4_key_press_eventgtk_focusgtk_key_press_eventgtk_mapgtk_realizegtk_scroll_childgtk_style_updatedhasBorderhookEventshooksKeysimHandleisLayoutDeferredisTabGrouplayoutlayoutlayoutlayoutlayoutmarkLayoutminimumSizemoveAbovemoveBelowmoveChildrenmustBeVisibleOnInitBoundsparentingHandleprintWidgetpropagateDrawredrawChildrenregisterreleaseHandlereleaseWidgetremoveControlresizeHandlesetBackgroundModesetFocussetLayoutsetLayoutDeferredsetOrientationsetScrollBarVisiblesetTabGroupFocussetTabItemFocussetTabListshowWidgettoStringtranslateMnemonictranslateTraversaltraversalCodeupdateBackgroundModeupdateLayout

Field Detail

caretback to summary
pack-priv Caret caret
drawFlagback to summary
pack-priv boolean drawFlag
imeback to summary
pack-priv IME ime

Constructor Detail

Canvasback to summary
pack-priv Canvas()
Canvasback to summary
public Canvas(Composite parent, int style)

Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.

The style value is either one of the style constants defined in class SWT which is applicable to instances of this class, or must be built by bitwise OR'ing together (that is, using the int "|" operator) two or more of those SWT style constants. The class description lists the style constants that are applicable to the class. Style bits are also inherited from superclasses.

Parameters
parent:Composite

a composite control which will be the parent of the new instance (cannot be null)

style:int

the style of control to construct

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the parent is null
SWTException:
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
See Also
SWT, Widget#getStyle

Method Detail

drawBackgroundback to summary
public void drawBackground(GC gc, int x, int y, int width, int height)

Fills the interior of the rectangle specified by the arguments, with the receiver's background.

Parameters
gc:GC

the gc where the rectangle is to be filled

x:int

the x coordinate of the rectangle to be filled

y:int

the y coordinate of the rectangle to be filled

width:int

the width of the rectangle to be filled

height:int

the height of the rectangle to be filled

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the gc is null
  • ERROR_INVALID_ARGUMENT - if the gc has been disposed
SWTException:
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
Since
3.2
drawCaretback to summary
private void drawCaret(long widget, long cairo)
drawCaretInFocusback to summary
pack-priv void drawCaretInFocus(long widget, long cairo)
getCaretback to summary
public Caret getCaret()

Returns the caret.

The caret for the control is automatically hidden and shown when the control is painted or resized, when focus is gained or lost and when an the control is scrolled. To avoid drawing on top of the caret, the programmer must hide and show the caret when drawing in the window any other time.

Returns:Caret

the caret for the receiver, may be null

Exceptions
SWTException:
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
getIMCaretPosback to summary
pack-priv Point getIMCaretPos()

Overrides org.eclipse.swt.widgets.Control.getIMCaretPos.

Annotations
@Override
getIMEback to summary
public IME getIME()

Returns the IME.

Returns:IME

the IME

Exceptions
SWTException:
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
Since
3.4
gtk_button_press_eventback to summary
pack-priv long gtk_button_press_event(long widget, long event)

Overrides org.eclipse.swt.widgets.Composite.gtk_button_press_event.

Annotations
@Override
gtk_commitback to summary
pack-priv long gtk_commit(long imcontext, long text)

Overrides org.eclipse.swt.widgets.Control.gtk_commit.

Annotations
@Override
gtk_drawback to summary
pack-priv long gtk_draw(long widget, long cairo)

Overrides org.eclipse.swt.widgets.Composite.gtk_draw.

Annotations
@Override
gtk_focus_in_eventback to summary
pack-priv long gtk_focus_in_event(long widget, long event)

Overrides org.eclipse.swt.widgets.Composite.gtk_focus_in_event.

Annotations
@Override
gtk_focus_out_eventback to summary
pack-priv long gtk_focus_out_event(long widget, long event)

Overrides org.eclipse.swt.widgets.Composite.gtk_focus_out_event.

Annotations
@Override
gtk_preedit_changedback to summary
pack-priv long gtk_preedit_changed(long imcontext)

Overrides org.eclipse.swt.widgets.Control.gtk_preedit_changed.

Annotations
@Override
redrawWidgetback to summary
pack-priv void redrawWidget(int x, int y, int width, int height, boolean redrawAll, boolean all, boolean trim)

Overrides org.eclipse.swt.widgets.Scrollable.redrawWidget.

Annotations
@Override
releaseChildrenback to summary
pack-priv void releaseChildren(boolean destroy)

Overrides org.eclipse.swt.widgets.Composite.releaseChildren.

Annotations
@Override
reskinChildrenback to summary
pack-priv void reskinChildren(int flags)

Overrides org.eclipse.swt.widgets.Composite.reskinChildren.

Annotations
@Override
scrollback to summary
public void scroll(int destX, int destY, int x, int y, int width, int height, boolean all)

Scrolls a rectangular area of the receiver by first copying the source area to the destination and then causing the area of the source which is not covered by the destination to be repainted. Children that intersect the rectangle are optionally moved during the operation. In addition, all outstanding paint events are flushed before the source area is copied to ensure that the contents of the canvas are drawn correctly.

Parameters
destX:int

the x coordinate of the destination

destY:int

the y coordinate of the destination

x:int

the x coordinate of the source

y:int

the y coordinate of the source

width:int

the width of the area

height:int

the height of the area

all:boolean

trueif children should be scrolled, and false otherwise

Exceptions
SWTException:
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
scrollInPixelsback to summary
pack-priv void scrollInPixels(int destX, int destY, int x, int y, int width, int height, boolean all)
setBoundsback to summary
pack-priv int setBounds(int x, int y, int width, int height, boolean move, boolean resize)

Overrides org.eclipse.swt.widgets.Composite.setBounds.

Annotations
@Override
setCaretback to summary
public void setCaret(Caret caret)

Sets the receiver's caret.

The caret for the control is automatically hidden and shown when the control is painted or resized, when focus is gained or lost and when an the control is scrolled. To avoid drawing on top of the caret, the programmer must hide and show the caret when drawing in the window any other time.

Parameters
caret:Caret

the new caret for the receiver, may be null

Exceptions
IllegalArgumentException:
  • ERROR_INVALID_ARGUMENT - if the caret has been disposed
SWTException:
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
setFontback to summary
public void setFont(Font font)

Overrides org.eclipse.swt.widgets.Control.setFont.

Doc from org.eclipse.swt.widgets.Control.setFont.

Sets the font that the receiver will use to paint textual information to the font specified by the argument, or to the default font for that kind of control if the argument is null.

Parameters
font:Font

the new font (or null)

Annotations
@Override
setIMEback to summary
public void setIME(IME ime)

Sets the receiver's IME.

Parameters
ime:IME

the new IME for the receiver, may be null

Exceptions
IllegalArgumentException:
  • ERROR_INVALID_ARGUMENT - if the IME has been disposed
SWTException:
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
Since
3.4
updateCaretback to summary
pack-priv void updateCaret()