Class Tracker
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: This class is not intended to be subclassed.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) Rectangle(package private) Boolean(package private) Rectangle(package private) Rectangle(package private) boolean(package private) Cursor(package private) int(package private) boolean(package private) long(package private) int(package private) int(package private) long(package private) Composite(package private) Rectangle[](package private) long(package private) Rectangle[](package private) static final int(package private) static final int(package private) boolean(package private) long(package private) boolean(package private) longFields inherited from class Widget
ACTIVATE, ACTIVATE_INVERSE, AUTO_TEXT_DIRECTION, BACKGROUND, BACKSPACE, BACKSPACE_INVERSE, BUTTON_PRESS_EVENT, BUTTON_PRESS_EVENT_INVERSE, BUTTON_RELEASE_EVENT, BUTTON_RELEASE_EVENT_INVERSE, CANVAS, CHANGE_VALUE, CHANGED, CHECK_SUBWINDOW, CLICKED, CLOSE_REQUEST, COMMIT, COMPUTE_SIZE, CONFIGURE_EVENT, COPY_CLIPBOARD, COPY_CLIPBOARD_INVERSE, CREATE_MENU_PROXY, CUT_CLIPBOARD, CUT_CLIPBOARD_INVERSE, data, DAY_SELECTED, DAY_SELECTED_DOUBLE_CLICK, DECELERATE, DEFAULT_HEIGHT, DEFAULT_WIDTH, DELETE_EVENT, DELETE_FROM_CURSOR, DELETE_FROM_CURSOR_INVERSE, DELETE_RANGE, DELETE_TEXT, DIRECTION_CHANGED, DISABLED, display, DISPOSE_SENT, DISPOSED, DPI_CHANGED, DRAG_DETECT, DRAW, ENTER, ENTER_NOTIFY_EVENT, EVENT, EVENT_AFTER, eventTable, EXPAND_COLLAPSE_CURSOR_ROW, EXPOSE_EVENT, EXPOSE_EVENT_INVERSE, FOCUS, FOCUS_IN, FOCUS_IN_EVENT, FOCUS_OUT, FOCUS_OUT_EVENT, FONT, FOREGROUND, FOREIGN_HANDLE, gdkSeatGrabPrepareFunc, GESTURE_PRESSED, GESTURE_RELEASED, GRAB_FOCUS, handle, HANDLE, HAS_AUTO_DIRECTION, HIDDEN, HIDE, ICON_RELEASE, IM_UPDATE, INPUT, INSERT_TEXT, IS_ACTIVE, KEY_CHECK_SUBWINDOW, KEY_GTK_CSS, KEY_PRESS_EVENT, KEY_PRESSED, KEY_RELEASE_EVENT, KEY_RELEASED, KEYED_DATA, LAST_SIGNAL, LAYOUT_CHANGED, LAYOUT_CHILD, LAYOUT_NEEDED, LEAVE, LEAVE_NOTIFY_EVENT, MAP, MAP_EVENT, MENU, MNEMONIC_ACTIVATE, MONTH_CHANGED, MOTION, MOTION_INVERSE, MOTION_NOTIFY_EVENT, MOTION_NOTIFY_EVENT_INVERSE, MOVE_CURSOR, MOVE_CURSOR_INVERSE, MOVE_FOCUS, MOVED, NOTIFY_DEFAULT_HEIGHT, NOTIFY_DEFAULT_WIDTH, NOTIFY_MAXIMIZED, NOTIFY_STATE, OBSCURED, OUTPUT, PARENT_BACKGROUND, PASTE_CLIPBOARD, PASTE_CLIPBOARD_INVERSE, POPPED_UP, POPULATE_POPUP, POPUP_MENU, PREEDIT_CHANGED, REALIZE, RELEASED, RESIZED, ROW_ACTIVATED, ROW_DELETED, ROW_HAS_CHILD_TOGGLED, ROW_INSERTED, SCROLL, SCROLL_BEGIN, SCROLL_CHILD, SCROLL_END, SCROLL_EVENT, SELECT, SELECTION_DONE, SHOW, SHOW_HELP, SIZE_ALLOCATE, SIZE_ALLOCATE_GTK4, SKIN_NEEDED, START_INTERACTIVE_SEARCH, state, STATUS_ICON_POPUP_MENU, style, STYLE_UPDATED, SWITCH_PAGE, TEST_COLLAPSE_ROW, TEST_EXPAND_ROW, TEXT_BUFFER_INSERT_TEXT, THEME_BACKGROUND, TOGGLED, UNMAP, UNMAP_EVENT, UNREALIZE, VALUE_CHANGED, WINDOW_STATE_EVENT, ZERO_HEIGHT, ZERO_WIDTH -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new instance of this class given its parent and a style value describing its behavior and appearance.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 TypeMethodDescriptionvoidaddControlListener(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 theControlListenerinterface.voidaddKeyListener(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 theKeyListenerinterface.(package private) Point(package private) Point(package private) static intcheckStyle(int style) voidclose()Stops displaying the tracker rectangles.(package private) Rectangle(package private) Rectangle[]computeProportions(Rectangle[] rects) (package private) voiddrawRectangles(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.Returns the bounds that are being drawn, expressed relative to the parent widget.booleanReturnstrueif the rectangles are drawn with a stippled line,falseotherwise.(package private) booleangrab()(package private) longgtk_button_release_event(long widget, long event) (package private) longgtk_motion_notify_event(long widget, long eventPtr) (package private) longgtk_mouse(int eventType, long widget, long eventPtr) (package private) longgtk3_key_press_event(long widget, long eventPtr) (package private) voidmoveRectangles(int xChange, int yChange) booleanopen()Displays the Tracker rectangles for manipulation by the user.(package private) booleanprocessEvent(long eventPtr) (package private) voidvoidremoveControlListener(ControlListener listener) Removes the listener from the collection of listeners who will be notified when the control is moved or resized.voidremoveKeyListener(KeyListener listener) Removes the listener from the collection of listeners who will be notified when keys are pressed and released on the system keyboard.(package private) voidresizeRectangles(int xChange, int yChange) voidSets theCursorof the Tracker.voidsetRectangles(Rectangle[] rectangles) Specifies the rectangles that should be drawn, expressed relative to the parent widget.voidsetStippled(boolean stippled) Changes the appearance of the line used to draw the rectangles.private voidsetTrackerBackground(boolean opaque) (package private) voidungrab()(package private) voidupdate()Methods inherited from class Widget
_addListener, addDisposeListener, addListener, addTypedListener, cellDataProc, checkBits, checkOpen, checkOrientation, checkParent, checkSubclass, checkWidget, convertPangoFontDescriptionToCss, createHandle, createWidget, cssHandle, deregister, destroyWidget, dispose, dpiChanged, enterMotionProc, error, filterProc, filters, fixMnemonic, fixMnemonic, fixMnemonic, focusProc, fontHeight, gdk_event_free, gdk_event_get_state, gdk_event_get_surface_or_window, gdk_pointer_grab, gdk_pointer_ungrab, gdk_surface_get_size, gdk_window_get_size, GdkSeatGrabPrepareFunc, gesturePressReleaseProc, getData, getData, getDisplay, getListeners, getName, getNameText, getStyle, getTypedListeners, gtk_activate, gtk_adjustment_get, gtk_box_new, gtk_box_pack_end, gtk_box_set_child_packing, gtk_button_press_event, gtk_cell_renderer_get_preferred_size, gtk_change_value, gtk_changed, gtk_clicked, gtk_close_request, gtk_commit, gtk_configure_event, gtk_container_get_border_width_or_margin, gtk_container_set_border_width, gtk_create_menu_proxy, gtk_day_selected, gtk_day_selected_double_click, gtk_delete_event, gtk_delete_range, gtk_delete_text, gtk_draw, gtk_enter_notify_event, gtk_expand_collapse_cursor_row, gtk_focus, gtk_focus_in_event, gtk_focus_out_event, gtk_gesture_press_event, gtk_gesture_release_event, gtk_grab_focus, gtk_hide, gtk_icon_release, gtk_input, gtk_insert_text, gtk_leave_notify_event, gtk_map, gtk_map_event, gtk_menu_popped_up, gtk_mnemonic_activate, gtk_month_changed, gtk_move_focus, gtk_output, gtk_populate_popup, gtk_preedit_changed, gtk_realize, gtk_row_activated, gtk_row_has_child_toggled, gtk_scroll_child, gtk_scroll_event, gtk_select, gtk_selection_done, gtk_show, gtk_size_allocate, gtk_start_interactive_search, gtk_status_icon_popup_menu, gtk_style_updated, gtk_switch_page, gtk_test_collapse_row, gtk_test_expand_row, gtk_text_buffer_insert_text, gtk_timer, gtk_toggled, gtk_tree_view_column_cell_get_position, gtk_unmap, gtk_unmap_event, gtk_unrealize, gtk_value_changed, gtk_widget_get_preferred_size, gtk_widget_get_surface, gtk_widget_get_window, gtk_widget_hide, gtk_widget_show, gtk_widget_size_allocate, gtk_window_state_event, gtk3_event_after, gtk3_key_release_event, gtk3_popup_menu, gtk3_show_help, gtk4_draw, gtk4_enter_event, gtk4_focus_enter_event, gtk4_focus_leave_event, gtk4_focus_window_event, gtk4_key_press_event, gtk4_key_release_event, gtk4_leave_event, gtk4_motion_event, gtk4_scroll_event, hookEvents, hooks, hoverProc, isActive, isAutoDirection, isDisposed, isListening, isValidSubclass, isValidThread, keyPressReleaseProc, leaveProc, mnemonicHit, mnemonicMatch, notifyCreationTracker, notifyDisposalTracker, notifyListeners, notifyProc, notifyState, paintSurface, paintWindow, postEvent, postEvent, register, release, releaseChildren, releaseHandle, releaseParent, removeDisposeListener, removeListener, removeListener, removeListener, removeTypedListener, rendererGetPreferredWidthProc, rendererRenderProc, rendererSnapshotProc, reskin, reskinChildren, reskinWidget, scrollProc, sendEvent, sendEvent, sendEvent, sendEvent, sendIMKeyEvent, sendKeyEvent, sendSelectionEvent, sendSelectionEvent, setButtonState, setData, setData, setFontDescription, setInputState, setKeyState, setLocationState, setOrientation, setTabGroupFocus, setTabItemFocus, setToolTipText, shellMapProc, sizeAllocateProc, sizeRequestProc, snapshotToDraw, timerProc, topHandle, toString, translateTraversal, windowActiveProc, windowProc, windowProc, windowProc, windowProc, windowProc
-
Field Details
-
parent
Composite parent -
cursor
Cursor cursor -
lastCursor
long lastCursor -
window
long window -
overlay
long overlay -
surface
long surface -
tracking
boolean tracking -
cancelled
boolean cancelled -
grabbed
boolean grabbed -
stippled
boolean stippled -
rectangles
Rectangle[] rectangles -
proportions
Rectangle[] proportions -
bounds
Rectangle bounds -
cursorOrientation
int cursorOrientation -
oldX
int oldX -
oldY
int oldY -
provider
long provider -
cachedCombinedDisplayResolution
Rectangle cachedCombinedDisplayResolution -
cachedUnion
Rectangle cachedUnion -
cachedBackgroundIsOpaque
Boolean cachedBackgroundIsOpaque -
STEPSIZE_SMALL
static final int STEPSIZE_SMALL- See Also:
-
STEPSIZE_LARGE
static final int STEPSIZE_LARGE- See Also:
-
-
Constructor Details
-
Tracker
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
SWTwhich is applicable to instances of this class, or must be built by bitwise OR'ing together (that is, using theint"|" operator) two or more of thoseSWTstyle constants. The class description lists the style constants that are applicable to the class. Style bits are also inherited from superclasses.- Parameters:
parent- a widget which will be the parent of the new instance (cannot be null)style- the style of widget to construct- Throws:
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:
-
Tracker
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
SWTwhich is applicable to instances of this class, or must be built by bitwise OR'ing together (that is, using theint"|" operator) two or more of thoseSWTstyle 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- the display to create the tracker onstyle- the style of control to construct- Throws:
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:
-
-
Method Details
-
addControlListener
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 theControlListenerinterface.- Parameters:
listener- the listener which should be notified- Throws:
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:
-
addKeyListener
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 theKeyListenerinterface.- Parameters:
listener- the listener which should be notified- Throws:
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:
-
adjustMoveCursor
Point adjustMoveCursor() -
adjustResizeCursor
Point adjustResizeCursor() -
close
public void close()Stops displaying the tracker rectangles. Note that this is not considered to be a cancelation by the user.- Throws:
SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
checkStyle
static int checkStyle(int style) -
computeBounds
Rectangle computeBounds() -
computeProportions
-
drawRectangles
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. -
getRectangles
Returns the bounds that are being drawn, expressed relative to the parent widget. If the parent is aDisplaythen these are screen coordinates.- Returns:
- the bounds of the Rectangles being drawn
- Throws:
SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
getStippled
public boolean getStippled()Returnstrueif the rectangles are drawn with a stippled line,falseotherwise.- Returns:
- the stippled effect of the rectangles
- Throws:
SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
grab
boolean grab() -
gtk_button_release_event
long gtk_button_release_event(long widget, long event) - Overrides:
gtk_button_release_eventin classWidget
-
gtk3_key_press_event
long gtk3_key_press_event(long widget, long eventPtr) - Overrides:
gtk3_key_press_eventin classWidget
-
gtk_motion_notify_event
long gtk_motion_notify_event(long widget, long eventPtr) - Overrides:
gtk_motion_notify_eventin classWidget
-
gtk_mouse
long gtk_mouse(int eventType, long widget, long eventPtr) -
moveRectangles
void moveRectangles(int xChange, int yChange) -
open
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:
trueif the user did not cancel the Tracker,falseotherwise- Throws:
SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
setTrackerBackground
private void setTrackerBackground(boolean opaque) -
processEvent
boolean processEvent(long eventPtr) -
releaseWidget
void releaseWidget()- Overrides:
releaseWidgetin classWidget
-
removeControlListener
Removes the listener from the collection of listeners who will be notified when the control is moved or resized.- Parameters:
listener- the listener which should no longer be notified- Throws:
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:
-
removeKeyListener
Removes the listener from the collection of listeners who will be notified when keys are pressed and released on the system keyboard.- Parameters:
listener- the listener which should no longer be notified- Throws:
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:
-
resizeRectangles
void resizeRectangles(int xChange, int yChange) -
setCursor
Sets theCursorof the Tracker. If this cursor isnullthen the cursor reverts to the default.- Parameters:
newCursor- the newCursorto display- Throws:
SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
setRectangles
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- the bounds of the rectangles to be drawn- Throws:
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
-
setStippled
public void setStippled(boolean stippled) Changes the appearance of the line used to draw the rectangles.- Parameters:
stippled-trueif rectangle should appear stippled- Throws:
SWTException-- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
-
ungrab
void ungrab() -
update
void update()
-