Class Canvas
- All Implemented Interfaces:
Drawable
- Direct Known Subclasses:
AnimatedProgress, CLabel, Decorations, GLCanvas, StyledText, TableCursor, TreeCursor
- 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:
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) boolean(package private) Caret(package private) boolean(package private) IMEFields inherited from class Composite
backgroundMode, childrenLowered, embeddedHandle, fixClipHandle, fixClipMap, imHandle, layout, layoutCount, NO_INPUT_METHOD, noChildDrawing, popupChild, socketHandle, tabListFields inherited from class Scrollable
horizontalBar, RESIZE_ON_GETCLIENTAREA, scrolledHandle, verticalBarFields inherited from class Control
accessible, autoScale, backgroundAlpha, backgroundImage, cachedNoBackground, checkScaleFactor, cssBackground, cssForeground, cursor, DISABLE_EMOJI, dragDetectionQueue, dragGesture, drawCount, drawRegion, enableWindow, eventRegion, firstFixedHandle, fixedHandle, font, gestureBegin, gestureEnd, gestureRotation, gestureSwipe, gestureZoom, keyController, labelRelation, lastInput, layoutData, menu, mouseDown, panGesture, parent, provider, redrawWindow, region, regionHandle, rotateGesture, toolTipText, zoomGestureFields 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddrawBackground(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.private voiddrawCaret(long widget, long cairo) (package private) voiddrawCaretInFocus(long widget, long cairo) getCaret()Returns the caret.(package private) PointgetIME()Returns the IME.(package private) longgtk_button_press_event(long widget, long event) (package private) longgtk_commit(long imcontext, long text) (package private) longgtk_draw(long widget, long cairo) (package private) longgtk_focus_in_event(long widget, long event) (package private) longgtk_focus_out_event(long widget, long event) (package private) longgtk_preedit_changed(long imcontext) (package private) void(package private) voidgtk4_focus_enter_event(long handle, long event) (package private) voidgtk4_focus_leave_event(long handle, long event) (package private) voidredrawWidget(int x, int y, int width, int height, boolean redrawAll, boolean all, boolean trim) (package private) voidreleaseChildren(boolean destroy) (package private) voidreskinChildren(int flags) voidscroll(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.(package private) intsetBounds(int x, int y, int width, int height, boolean move, boolean resize) voidSets the receiver's caret.voidSets 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.voidSets the receiver's IME.(package private) voidMethods inherited from class Composite
_getChildren, _getTabList, adjustChildClipping, applyThemeBackground, changed, checkBuffered, checkStyle, checkSubclass, checkSubwindow, computeSizeInPixels, computeTabList, connectFixedHandleDraw, createHandle, createHandle, deregister, drawBackground, enableWidget, findDeferredControl, findMenus, fixChildren, fixClippings, fixModal, fixParentGdkResource, fixStyle, fixTabList, fixZOrder, focusHandle, forceFocus, getBackgroundMode, getChildren, getChildrenCount, getClientAreaInPixels, getLayout, getLayoutDeferred, getTabList, gtk_focus, gtk_map, gtk_realize, gtk_scroll_child, gtk_style_updated, gtk3_key_press_event, gtk4_key_press_event, hasBorder, hookEvents, hooksKeys, imHandle, isLayoutDeferred, isTabGroup, layout, layout, layout, layout, layout, markLayout, minimumSize, moveAbove, moveBelow, moveChildren, mustBeVisibleOnInitBounds, parentingHandle, printWidget, propagateDraw, redrawChildren, register, releaseHandle, releaseWidget, removeControl, resizeHandle, setBackgroundMode, setFocus, setLayout, setLayoutDeferred, setOrientation, setScrollBarVisible, setTabGroupFocus, setTabItemFocus, setTabList, showWidget, toString, translateMnemonic, translateTraversal, traversalCode, updateBackgroundMode, updateLayoutMethods inherited from class Scrollable
clientHandle, computeTrim, computeTrimInPixels, createScrollBar, createWidget, destroyScrollBar, getBorderWidthInPixels, getClientArea, getHorizontalBar, getScrollbarsMode, getVerticalBar, gtk_scroll_event, hScrollBarWidth, redrawBackgroundImage, sendLeaveNotify, setScrollbarsMode, topHandle, updateScrollBarValue, vScrollBarWidthMethods inherited from class Control
_getAccessible, _getShell, addControlListener, addDragDetectListener, addFocusListener, addGestureListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addRelation, addTouchListener, addTraverseListener, cairoClipRegion, cairoCopyRegion, cairoDisposeRegion, checkBackground, checkBorder, checkMirrored, cleanupEnableWindow, computeNativeSize, computeSize, computeSize, computeSizeInPixels, computeTabGroup, computeTabRoot, containedInRegion, defaultBackground, defaultFont, destroyWidget, dragDetect, dragDetect, dragDetect, dragDetect, drawBackground, drawGripper, drawWidget, enterExitHandle, eventHandle, eventSurface, eventWindow, filterKey, findBackgroundControl, fixFocus, fixGdkEventTypeValues, fixStyle, flushQueueOnDnd, fontHandle, forceFocus, forceResize, gestureBeginProc, gestureEndProc, gestureHandle, getAccessible, getBackground, getBackgroundGdkRGBA, getBackgroundImage, getBaseGdkRGBA, getBgGdkRGBA, getBorderWidth, getBounds, getBoundsInPixels, getClientWidth, getContextBackgroundGdkRGBA, getContextColorGdkRGBA, getControl, getControlOrigin, getCursor, getDragDetect, getEnabled, getFont, getFontDescription, getForeground, getForegroundGdkRGBA, getLayoutData, getLocation, getLocationInPixels, getMenu, getMonitor, getOrientation, getParent, getPath, getRegion, getShell, getSize, getSizeInPixels, getSurfaceOrigin, getTextDirection, getThickness, getToolTipText, getTouchEnabled, getVisible, getWindowOrigin, gtk_button_press_event, gtk_button_release_event, gtk_css_provider_load_from_css, gtk_enter_notify_event, gtk_gesture_press_event, gtk_gesture_release_event, gtk_label_set_align, gtk_leave_notify_event, gtk_mnemonic_activate, gtk_motion_notify_event, gtk_style_context_get_border, gtk_style_context_get_padding, gtk_unrealize, gtk_widget_reparent, gtk_widget_set_align, gtk3_event_after, gtk3_key_release_event, gtk3_popup_menu, gtk3_show_help, gtk4_enter_event, gtk4_focus_window_event, gtk4_key_release_event, gtk4_leave_event, gtk4_motion_event, gtk4_scroll_event, hasFocus, hooksPaint, hoverProc, internal_dispose_GC, internal_new_GC, isActive, isAutoScalable, isDescribedByLabel, isEnabled, isFocusAncestor, isFocusControl, isFocusHandle, isReparentable, isShowing, isTabItem, isVisible, magnifyProc, menuShell, mnemonicHit, mnemonicMatch, moveAbove, moveBelow, moveHandle, pack, pack, paintHandle, paintSurface, paintWindow, print, printWindow, redraw, redraw, redraw, release, releaseParent, removeControlListener, removeDragDetectListener, removeFocusListener, removeGestureListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeRelation, removeTouchListener, removeTraverseListener, requestLayout, resizeCalculationsGTK3, restackWindow, rotateProc, sendDragEvent, sendFocusEvent, sendGestureEvent, sendGestureEvent, sendGestureEvent, sendHelpEvent, sendMouseEvent, sendMouseEvent, setBackground, setBackground, setBackgroundGdkRGBA, setBackgroundGdkRGBA, setBackgroundGdkRGBA, setBackgroundImage, setBackgroundSurface, setBounds, setBounds, setBoundsInPixels, setBoundsInPixels, setCapture, setCursor, setCursor, setDragDetect, setEnabled, setFontDescription, setForeground, setForegroundGdkRGBA, setForegroundGdkRGBA, setInitialBounds, setLayoutData, setLocation, setLocation, setLocationInPixels, setLocationInPixels, setMenu, setOrientation, setParent, setParentBackground, setParentGdkResource, setRadioSelection, setRedraw, setRegion, setRelations, setSize, setSize, setSizeInPixels, setSizeInPixels, setTextDirection, setToolTipText, setToolTipText, setTouchEnabled, setVisible, setWidgetBackground, setZOrder, setZOrder, showMenu, showMenu, sort, swipeProc, toControl, toControl, toDisplay, toDisplay, toDisplayInPixels, translateMnemonic, traverse, traverse, traverse, traverse, traverse, traverseEscape, traverseGroup, traverseItem, traverseMnemonic, traversePage, traverseReturn, update, update, wantDragDropDetection, windowProcMethods inherited from class Widget
_addListener, addDisposeListener, addListener, addTypedListener, cellDataProc, checkBits, checkOpen, checkOrientation, checkParent, checkWidget, convertPangoFontDescriptionToCss, cssHandle, 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_cell_renderer_get_preferred_size, gtk_change_value, gtk_changed, gtk_clicked, gtk_close_request, 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_expand_collapse_cursor_row, gtk_grab_focus, gtk_hide, gtk_icon_release, gtk_input, gtk_insert_text, gtk_map_event, gtk_menu_popped_up, gtk_month_changed, gtk_move_focus, gtk_output, gtk_populate_popup, gtk_row_activated, gtk_row_has_child_toggled, gtk_select, gtk_selection_done, gtk_show, gtk_size_allocate, gtk_start_interactive_search, gtk_status_icon_popup_menu, 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_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, hooks, isAutoDirection, isDisposed, isListening, isValidSubclass, isValidThread, keyPressReleaseProc, leaveProc, mnemonicHit, mnemonicMatch, notifyCreationTracker, notifyDisposalTracker, notifyListeners, notifyProc, notifyState, postEvent, postEvent, removeDisposeListener, removeListener, removeListener, removeListener, removeTypedListener, rendererGetPreferredWidthProc, rendererRenderProc, rendererSnapshotProc, reskin, reskinWidget, scrollProc, sendEvent, sendEvent, sendEvent, sendEvent, sendIMKeyEvent, sendKeyEvent, sendSelectionEvent, sendSelectionEvent, setButtonState, setData, setData, setFontDescription, setInputState, setKeyState, setLocationState, setToolTipText, shellMapProc, sizeAllocateProc, sizeRequestProc, snapshotToDraw, timerProc, translateTraversal, windowActiveProc, windowProc, windowProc, windowProc, windowProc
-
Field Details
-
Constructor Details
-
Canvas
Canvas() -
Canvas
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 composite control which will be the parent of the new instance (cannot be null)style- the style of control 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
- See Also:
-
-
Method Details
-
drawBackground
Fills the interior of the rectangle specified by the arguments, with the receiver's background.- Parameters:
gc- the gc where the rectangle is to be filledx- the x coordinate of the rectangle to be filledy- the y coordinate of the rectangle to be filledwidth- the width of the rectangle to be filledheight- the height of the rectangle to be filled- Throws:
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
-
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:
- the caret for the receiver, may be null
- 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
-
getIMCaretPos
Point getIMCaretPos()- Overrides:
getIMCaretPosin classControl
-
getIME
Returns the IME.- Returns:
- the IME
- 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
- Since:
- 3.4
-
gtk_button_press_event
long gtk_button_press_event(long widget, long event) - Overrides:
gtk_button_press_eventin classComposite
-
gtk_commit
long gtk_commit(long imcontext, long text) - Overrides:
gtk_commitin classControl
-
gtk_draw
-
gtk4_draw
-
drawCaretInFocus
void drawCaretInFocus(long widget, long cairo) -
drawCaret
private void drawCaret(long widget, long cairo) -
gtk_focus_in_event
long gtk_focus_in_event(long widget, long event) - Overrides:
gtk_focus_in_eventin classComposite
-
gtk_focus_out_event
long gtk_focus_out_event(long widget, long event) - Overrides:
gtk_focus_out_eventin classComposite
-
gtk4_focus_enter_event
void gtk4_focus_enter_event(long handle, long event) - Overrides:
gtk4_focus_enter_eventin classControl- Parameters:
handle- the corresponding controller responsible for capturing the eventevent- the GdkEvent captured
-
gtk4_focus_leave_event
void gtk4_focus_leave_event(long handle, long event) - Overrides:
gtk4_focus_leave_eventin classControl- Parameters:
handle- the corresponding controller responsible for capturing the eventevent- the GdkEvent captured
-
gtk_preedit_changed
long gtk_preedit_changed(long imcontext) - Overrides:
gtk_preedit_changedin classControl
-
redrawWidget
void redrawWidget(int x, int y, int width, int height, boolean redrawAll, boolean all, boolean trim) - Overrides:
redrawWidgetin classScrollable
-
releaseChildren
void releaseChildren(boolean destroy) - Overrides:
releaseChildrenin classComposite
-
reskinChildren
void reskinChildren(int flags) - Overrides:
reskinChildrenin classComposite
-
scroll
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- the x coordinate of the destinationdestY- the y coordinate of the destinationx- the x coordinate of the sourcey- the y coordinate of the sourcewidth- the width of the areaheight- the height of the areaall-trueif children should be scrolled, andfalseotherwise- 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
-
setBounds
-
setCaret
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- the new caret for the receiver, may be null- Throws:
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
-
setFont
Description copied from class:ControlSets 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. -
setIME
Sets the receiver's IME.- Parameters:
ime- the new IME for the receiver, may be null- Throws:
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
-
updateCaret
void updateCaret()
-