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

public Class Tracker

extends Widget
Class Inheritance
Imports
org.eclipse.swt.*, org.eclipse.swt.events.*, org.eclipse.swt.graphics.*, org.eclipse.swt.internal.*, org.eclipse.swt.internal.cairo.*, org.eclipse.swt.internal.gtk.*, org.eclipse.swt.internal.gtk3.*, org.eclipse.swt.internal.gtk4.*

Instances of this class implement rubber banding rectangles that are drawn onto a parent Composite or Display. These rectangles can be specified to respond to mouse and key events by either moving or resizing themselves accordingly. Trackers are typically used to represent window geometries in a lightweight manner.
Styles:
LEFT, RIGHT, UP, DOWN, RESIZE
Events:
Move, Resize

Note

Rectangle move behavior is assumed unless RESIZE is specified.

Important Note

This class is not intended to be subclassed.

See Also
Tracker snippets, Sample code and further information

Field Summary

Modifier and TypeField and Description
pack-priv Rectangle
pack-priv Boolean
pack-priv Rectangle
pack-priv Rectangle
pack-priv boolean
pack-priv Cursor
pack-priv int
pack-priv boolean
pack-priv long
pack-priv int
pack-priv int
pack-priv long
pack-priv Composite
pack-priv Rectangle[]
pack-priv long
pack-priv Rectangle[]
pack-priv static final int
pack-priv static final int
pack-priv boolean
pack-priv long
pack-priv boolean
pack-priv long
Inherited from org.eclipse.swt.widgets.Widget:
ACTIVATEACTIVATE_INVERSEAUTO_TEXT_DIRECTIONBACKGROUNDBACKSPACEBACKSPACE_INVERSEBUTTON_PRESS_EVENTBUTTON_PRESS_EVENT_INVERSEBUTTON_RELEASE_EVENTBUTTON_RELEASE_EVENT_INVERSECANVASCHANGE_VALUECHANGEDCHECK_SUBWINDOWCLICKEDCLOSE_REQUESTCOMMITCOMPUTE_SIZECONFIGURE_EVENTCOPY_CLIPBOARDCOPY_CLIPBOARD_INVERSECREATE_MENU_PROXYCUT_CLIPBOARDCUT_CLIPBOARD_INVERSEdataDAY_SELECTEDDAY_SELECTED_DOUBLE_CLICKDECELERATEDEFAULT_HEIGHTDEFAULT_WIDTHDELETE_EVENTDELETE_FROM_CURSORDELETE_FROM_CURSOR_INVERSEDELETE_RANGEDELETE_TEXTDIRECTION_CHANGEDDISABLEDdisplayDISPOSE_SENTDISPOSEDDPI_CHANGEDDRAG_DETECTDRAWENTERENTER_NOTIFY_EVENTEVENTEVENT_AFTEReventTableEXPAND_COLLAPSE_CURSOR_ROWEXPOSE_EVENTEXPOSE_EVENT_INVERSEFOCUSFOCUS_INFOCUS_IN_EVENTFOCUS_OUTFOCUS_OUT_EVENTFONTFOREGROUNDFOREIGN_HANDLEgdkSeatGrabPrepareFuncGESTURE_PRESSEDGESTURE_RELEASEDGRAB_FOCUShandleHANDLEHAS_AUTO_DIRECTIONHIDDENHIDEICON_RELEASEIM_UPDATEINPUTINSERT_TEXTIS_ACTIVEKEY_CHECK_SUBWINDOWKEY_GTK_CSSKEY_PRESS_EVENTKEY_PRESSEDKEY_RELEASE_EVENTKEY_RELEASEDKEYED_DATALAST_SIGNALLAYOUT_CHANGEDLAYOUT_CHILDLAYOUT_NEEDEDLEAVELEAVE_NOTIFY_EVENTMAPMAP_EVENTMENUMNEMONIC_ACTIVATEMONTH_CHANGEDMOTIONMOTION_INVERSEMOTION_NOTIFY_EVENTMOTION_NOTIFY_EVENT_INVERSEMOVE_CURSORMOVE_CURSOR_INVERSEMOVE_FOCUSMOVEDNOTIFY_DEFAULT_HEIGHTNOTIFY_DEFAULT_WIDTHNOTIFY_MAXIMIZEDNOTIFY_STATEOBSCUREDOUTPUTPARENT_BACKGROUNDPASTE_CLIPBOARDPASTE_CLIPBOARD_INVERSEPOPPED_UPPOPULATE_POPUPPOPUP_MENUPREEDIT_CHANGEDREALIZERELEASEDRESIZEDROW_ACTIVATEDROW_DELETEDROW_HAS_CHILD_TOGGLEDROW_INSERTEDSCROLLSCROLL_BEGINSCROLL_CHILDSCROLL_ENDSCROLL_EVENTSELECTSELECTION_DONESHOWSHOW_HELPSIZE_ALLOCATESIZE_ALLOCATE_GTK4SKIN_NEEDEDSTART_INTERACTIVE_SEARCHstateSTATUS_ICON_POPUP_MENUstyleSTYLE_UPDATEDSWITCH_PAGETEST_COLLAPSE_ROWTEST_EXPAND_ROWTEXT_BUFFER_INSERT_TEXTTHEME_BACKGROUNDTOGGLEDUNMAPUNMAP_EVENTUNREALIZEVALUE_CHANGEDWINDOW_STATE_EVENTZERO_HEIGHTZERO_WIDTH

Constructor Summary

AccessConstructor and Description
public
Tracker(Composite
a widget which will be the parent of the new instance (cannot be null)
parent
,
int
the style of widget to construct
style
)

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

public
Tracker(Display
the display to create the tracker on
display
,
int
the style of control to construct
style
)

Constructs a new instance of this class given the display to create it on and a style value describing its behavior and appearance.

Method Summary

Modifier and TypeMethod and Description
public void
addControlListener(ControlListener
the listener which should be notified
listener
)

Adds the listener to the collection of listeners who will be notified when the control is moved or resized, by sending it one of the messages defined in the ControlListener interface.

public void
addKeyListener(KeyListener
the listener which should be notified
listener
)

Adds the listener to the collection of listeners who will be notified when keys are pressed and released on the system keyboard, by sending it one of the messages defined in the KeyListener interface.

pack-priv Point
pack-priv Point
pack-priv static int
checkStyle(int style)

public void
close()

Stops displaying the tracker rectangles.

pack-priv Rectangle
pack-priv Rectangle[]
pack-priv void
drawRectangles(Rectangle[] rects)

Developer note: - Rectangles can have absolute coords [Tracker(Display)] or relative to parent [Tracker(Composite)] - This method is called a lot, optimize your code.

public Rectangle[]

Returns:

the bounds of the Rectangles being drawn
getRectangles
()

Returns the bounds that are being drawn, expressed relative to the parent widget.

pack-priv Rectangle[]
public boolean

Returns:

the stippled effect of the rectangles
getStippled
()

Returns true if the rectangles are drawn with a stippled line, false otherwise.

pack-priv boolean
grab()

pack-priv long
pack-priv long
pack-priv long
pack-priv long
gtk_mouse(int eventType, long widget, long eventPtr)

pack-priv void
moveRectangles(int xChange, int yChange)

public boolean

Returns:

true if the user did not cancel the Tracker, false otherwise
open
()

Displays the Tracker rectangles for manipulation by the user.

pack-priv boolean
processEvent(long eventPtr)

pack-priv void
public void
removeControlListener(ControlListener
the listener which should no longer be notified
listener
)

Removes the listener from the collection of listeners who will be notified when the control is moved or resized.

public void
removeKeyListener(KeyListener
the listener which should no longer be notified
listener
)

Removes the listener from the collection of listeners who will be notified when keys are pressed and released on the system keyboard.

pack-priv void
resizeRectangles(int xChange, int yChange)

public void
setCursor(Cursor
the new Cursor to display
newCursor
)

Sets the Cursor of the Tracker.

public void
setRectangles(Rectangle[]
the bounds of the rectangles to be drawn
rectangles
)

Specifies the rectangles that should be drawn, expressed relative to the parent widget.

pack-priv void
public void
setStippled(boolean
true if rectangle should appear stippled
stippled
)

Changes the appearance of the line used to draw the rectangles.

private void
setTrackerBackground(boolean opaque)

pack-priv void
pack-priv void
Inherited from org.eclipse.swt.widgets.Widget:
_addListeneraddDisposeListeneraddListenercellDataProccheckBitscheckOpencheckOrientationcheckParentcheckSubclasscheckWidgetconvertPangoFontDescriptionToCsscreateHandlecreateWidgetcssHandlederegisterdestroyWidgetdisposedpiChangedenterMotionProcerrorfilterProcfiltersfixMnemonicfixMnemonicfixMnemonicfocusProcfontHeightgdk_event_freegdk_event_get_stategdk_event_get_surface_or_windowgdk_pointer_grabgdk_pointer_ungrabgdk_surface_get_sizegdk_window_get_sizeGdkSeatGrabPrepareFuncgesturePressReleaseProcgetDatagetDatagetDisplaygetListenersgetNamegetNameTextgetStylegtk3_show_helpgtk4_drawgtk4_enter_eventgtk4_focus_enter_eventgtk4_focus_leave_eventgtk4_focus_window_eventgtk4_key_press_eventgtk4_key_release_eventgtk4_leave_eventgtk4_motion_eventgtk4_scroll_eventgtk_activategtk_adjustment_getgtk_box_newgtk_box_pack_endgtk_box_set_child_packinggtk_button_press_eventgtk_cell_renderer_get_preferred_sizegtk_change_valuegtk_changedgtk_clickedgtk_close_requestgtk_commitgtk_configure_eventgtk_container_get_border_width_or_margingtk_container_set_border_widthgtk_create_menu_proxygtk_day_selectedgtk_day_selected_double_clickgtk_delete_eventgtk_delete_rangegtk_delete_textgtk_drawgtk_enter_notify_eventgtk_event_aftergtk_expand_collapse_cursor_rowgtk_focusgtk_focus_in_eventgtk_focus_out_eventgtk_gesture_press_eventgtk_gesture_release_eventgtk_grab_focusgtk_hidegtk_icon_releasegtk_inputgtk_insert_textgtk_key_release_eventgtk_leave_notify_eventgtk_mapgtk_map_eventgtk_menu_popped_upgtk_mnemonic_activategtk_month_changedgtk_move_focusgtk_outputgtk_populate_popupgtk_popup_menugtk_preedit_changedgtk_realizegtk_row_activatedgtk_row_has_child_toggledgtk_scroll_childgtk_scroll_eventgtk_selectgtk_selection_donegtk_showgtk_size_allocategtk_start_interactive_searchgtk_status_icon_popup_menugtk_style_updatedgtk_switch_pagegtk_test_collapse_rowgtk_test_expand_rowgtk_text_buffer_insert_textgtk_timergtk_toggledgtk_tree_view_column_cell_get_positiongtk_unmapgtk_unmap_eventgtk_unrealizegtk_value_changedgtk_widget_get_preferred_sizegtk_widget_get_surfacegtk_widget_get_windowgtk_widget_size_allocategtk_window_state_eventhookEventshookshoverProcisActiveisAutoDirectionisDisposedisListeningisValidSubclassisValidThreadkeyPressReleaseProcleaveProcmnemonicHitmnemonicMatchnotifyCreationTrackernotifyDisposalTrackernotifyListenersnotifyProcnotifyStatepaintSurfacepaintWindowpostEventpostEventregisterreleasereleaseChildrenreleaseHandlereleaseParentremoveDisposeListenerremoveListenerremoveListenerrendererGetPreferredWidthProcrendererRenderProcrendererSnapshotProcreskinreskinChildrenreskinWidgetscrollProcsendEventsendEventsendEventsendEventsendIMKeyEventsendKeyEventsendSelectionEventsendSelectionEventsetButtonStatesetDatasetDatasetFontDescriptionsetInputStatesetKeyStatesetLocationStatesetOrientationsetTabGroupFocussetTabItemFocussetToolTipTextshellMapProcsizeAllocateProcsizeRequestProcsnapshotToDrawtimerProctopHandletoStringtranslateTraversalwindowActiveProcwindowProcwindowProcwindowProcwindowProcwindowProc

Field Detail

boundsback to summary
pack-priv Rectangle bounds
cachedBackgroundIsOpaqueback to summary
pack-priv Boolean cachedBackgroundIsOpaque
cachedCombinedDisplayResolutionback to summary
pack-priv Rectangle cachedCombinedDisplayResolution
cachedUnionback to summary
pack-priv Rectangle cachedUnion
cancelledback to summary
pack-priv boolean cancelled
cursorback to summary
pack-priv Cursor cursor
cursorOrientationback to summary
pack-priv int cursorOrientation
grabbedback to summary
pack-priv boolean grabbed
lastCursorback to summary
pack-priv long lastCursor
oldXback to summary
pack-priv int oldX
oldYback to summary
pack-priv int oldY
overlayback to summary
pack-priv long overlay
parentback to summary
pack-priv Composite parent
proportionsback to summary
pack-priv Rectangle[] proportions
providerback to summary
pack-priv long provider
rectanglesback to summary
pack-priv Rectangle[] rectangles
STEPSIZE_LARGEback to summary
pack-priv static final int STEPSIZE_LARGE
STEPSIZE_SMALLback to summary
pack-priv static final int STEPSIZE_SMALL
stippledback to summary
pack-priv boolean stippled
surfaceback to summary
pack-priv long surface
trackingback to summary
pack-priv boolean tracking
windowback to summary
pack-priv long window

Constructor Detail

Trackerback to summary
public Tracker(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 widget which will be the parent of the new instance (cannot be null)

style:int

the style of widget 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
  • ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass
See Also
SWT#LEFT, SWT#RIGHT, SWT#UP, SWT#DOWN, SWT#RESIZE, Widget#checkSubclass, Widget#getStyle
Trackerback to summary
public Tracker(Display display, int style)

Constructs a new instance of this class given the display to create it on 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.

Note

Currently, null can be passed in for the display argument. This has the effect of creating the tracker on the currently active display if there is one. If there is no current display, the tracker is created on a "default" display. Passing in null as the display argument is not considered to be good coding style, and may not be supported in a future release of SWT.

Parameters
display:Display

the display to create the tracker on

style:int

the style of control to construct

Exceptions
SWTException:
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
  • ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass
See Also
SWT#LEFT, SWT#RIGHT, SWT#UP, SWT#DOWN, SWT#RESIZE

Method Detail

addControlListenerback to summary
public void addControlListener(ControlListener listener)

Adds the listener to the collection of listeners who will be notified when the control is moved or resized, by sending it one of the messages defined in the ControlListener interface.

Parameters
listener:ControlListener

the listener which should be notified

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the listener is null
SWTException:
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
See Also
ControlListener, removeControlListener
addKeyListenerback to summary
public void addKeyListener(KeyListener listener)

Adds the listener to the collection of listeners who will be notified when keys are pressed and released on the system keyboard, by sending it one of the messages defined in the KeyListener interface.

Parameters
listener:KeyListener

the listener which should be notified

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the listener is null
SWTException:
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
See Also
KeyListener, removeKeyListener
adjustMoveCursorback to summary
pack-priv Point adjustMoveCursor()
adjustResizeCursorback to summary
pack-priv Point adjustResizeCursor()
checkStyleback to summary
pack-priv static int checkStyle(int style)
closeback to summary
public void close()

Stops displaying the tracker rectangles. Note that this is not considered to be a cancelation by the user.

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
computeBoundsback to summary
pack-priv Rectangle computeBounds()
computeProportionsback to summary
pack-priv Rectangle[] computeProportions(Rectangle[] rects)
drawRectanglesback to summary
pack-priv void drawRectangles(Rectangle[] rects)

Developer note: - Rectangles can have absolute coords [Tracker(Display)] or relative to parent [Tracker(Composite)] - This method is called a lot, optimize your code. - Note, region != rectangle. A region can have a non-squared form, e.g an 'L' shape.

getRectanglesback to summary
public Rectangle[] getRectangles()

Returns the bounds that are being drawn, expressed relative to the parent widget. If the parent is a Display then these are screen coordinates.

Returns:Rectangle[]

the bounds of the Rectangles being drawn

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
getRectanglesInPixelsback to summary
pack-priv Rectangle[] getRectanglesInPixels()
getStippledback to summary
public boolean getStippled()

Returns true if the rectangles are drawn with a stippled line, false otherwise.

Returns:boolean

the stippled effect of the rectangles

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
grabback to summary
pack-priv boolean grab()
gtk_button_release_eventback to summary
pack-priv long gtk_button_release_event(long widget, long event)

Overrides org.eclipse.swt.widgets.Widget.gtk_button_release_event.

Annotations
@Override
gtk_key_press_eventback to summary
pack-priv long gtk_key_press_event(long widget, long eventPtr)

Overrides org.eclipse.swt.widgets.Widget.gtk_key_press_event.

Annotations
@Override
gtk_motion_notify_eventback to summary
pack-priv long gtk_motion_notify_event(long widget, long eventPtr)

Overrides org.eclipse.swt.widgets.Widget.gtk_motion_notify_event.

Annotations
@Override
gtk_mouseback to summary
pack-priv long gtk_mouse(int eventType, long widget, long eventPtr)
moveRectanglesback to summary
pack-priv void moveRectangles(int xChange, int yChange)
openback to summary
public boolean open()

Displays the Tracker rectangles for manipulation by the user. Returns when the user has either finished manipulating the rectangles or has cancelled the Tracker.

Returns:boolean

true if the user did not cancel the Tracker, 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
processEventback to summary
pack-priv boolean processEvent(long eventPtr)
releaseWidgetback to summary
pack-priv void releaseWidget()

Overrides org.eclipse.swt.widgets.Widget.releaseWidget.

Annotations
@Override
removeControlListenerback to summary
public void removeControlListener(ControlListener listener)

Removes the listener from the collection of listeners who will be notified when the control is moved or resized.

Parameters
listener:ControlListener

the listener which should no longer be notified

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the listener is null
SWTException:
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
See Also
ControlListener, addControlListener
removeKeyListenerback to summary
public void removeKeyListener(KeyListener listener)

Removes the listener from the collection of listeners who will be notified when keys are pressed and released on the system keyboard.

Parameters
listener:KeyListener

the listener which should no longer be notified

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the listener is null
SWTException:
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
See Also
KeyListener, addKeyListener
resizeRectanglesback to summary
pack-priv void resizeRectangles(int xChange, int yChange)
setCursorback to summary
public void setCursor(Cursor newCursor)

Sets the Cursor of the Tracker. If this cursor is null then the cursor reverts to the default.

Parameters
newCursor:Cursor

the new Cursor to display

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
setRectanglesback to summary
public void setRectangles(Rectangle[] rectangles)

Specifies the rectangles that should be drawn, expressed relative to the parent widget. If the parent is a Display then these are screen coordinates.

Parameters
rectangles:Rectangle[]

the bounds of the rectangles to be drawn

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the set of rectangles is null or contains a null rectangle
SWTException:
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
setRectanglesInPixelsback to summary
pack-priv void setRectanglesInPixels(Rectangle[] rectangles)
setStippledback to summary
public void setStippled(boolean stippled)

Changes the appearance of the line used to draw the rectangles.

Parameters
stippled:boolean

true if rectangle should appear stippled

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
setTrackerBackgroundback to summary
private void setTrackerBackground(boolean opaque)
ungrabback to summary
pack-priv void ungrab()
updateback to summary
pack-priv void update()