Package com._1c.g5.lwt.interop
Class SwtLightControl
java.lang.Object
com._1c.g5.lwt.interop.SwtLightControl
- All Implemented Interfaces:
ILightControl
- Direct Known Subclasses:
SwtLightComposite
Wraps the native SWT controls to abstract the difference between
the native and light controls.
-
Constructor Summary
ConstructorsConstructorDescriptionSwtLightControl(org.eclipse.swt.widgets.Control swtControl) Instantiates a new SWT light control. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddControlListener(ILightControlListener listener) Adds the control listener.org.eclipse.swt.graphics.PointcomputeSize(org.eclipse.swt.graphics.GC gc, int width, int height, boolean flushCache) Computes the size of this control.static booleancontainsWidget(ILightControl control, org.eclipse.swt.widgets.Widget widget) Checks whether a light control contains an SWT widget.voiddispose()Disposes this control.protected voiddisposed()Invoked when the control is disposed from the SWT side.org.eclipse.swt.graphics.RectangleGets the bounds of this control.org.eclipse.swt.graphics.CursorGets the cursor of this control.Gets the user defined data associated with this control.static org.eclipse.swt.widgets.DisplaygetHostDisplay(ILightControl control) Obtains the hostingDisplayfor the given control.static SwtLightControlgetHostSwtLightControl(org.eclipse.swt.widgets.Widget widget) Obtains the hostingSwtLightCompositefor the given SWT widget.Gets the layout data of this control.Gets the overlay source if this control is an overlay.Gets the parent of this control.org.eclipse.swt.widgets.ControlGets the associated native SWT control.static SwtLightControlgetSwtLightControl(org.eclipse.swt.widgets.Widget widget) Obtains theSwtLightControlfor a given widget.Gets the tooltip of this control.org.eclipse.swt.graphics.RectanglevoidhandleEvent(org.eclipse.swt.widgets.Event event) Handles the SWT event, SWT events are pumped to this method if this control is active.voidInvalidates the bounds of this control.voidinvalidate(org.eclipse.swt.graphics.Rectangle rectangle) Invalidates the given rectangle of this control.booleanChecks if control this is disposed.booleanChecks if this is enabled.booleanChecks if this control is focused.booleanChecks if this control is visible.voidpaint(org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle rectangle) Paints the given rectangle of this control.voidremoveControlListener(ILightControlListener listener) Removes the control listener.voidsetBounds(org.eclipse.swt.graphics.Rectangle bounds) Sets the bounds of this control.voidsetCursor(org.eclipse.swt.graphics.Cursor cursor) Sets the cursor of this control.voidSets the user-defined data associated with this control.voidsetEnabled(boolean enabled) Sets this control enablement.booleansetFocus(FocusSource focusSource) Sets the focus to this control.voidsetLayoutData(ILightLayoutData layoutData) Sets the layout data of this control.voidsetOverlaySource(ILightControl control) Sets the overlay source.voidsetParent(ILightComposite parent) Sets the parent of this control.voidsetTooltip(String tooltip) Sets the tooltip of this control.voidsetVisible(boolean value) Sets this control visibility.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com._1c.g5.lwt.ILightControl
initialize
-
Constructor Details
-
SwtLightControl
public SwtLightControl(org.eclipse.swt.widgets.Control swtControl) Instantiates a new SWT light control.- Parameters:
swtControl- the native SWT control to create a wrapper for.
-
-
Method Details
-
getSwtLightControl
Obtains theSwtLightControlfor a given widget.- Parameters:
widget- the widget to obtain the light wrapper of.- Returns:
- obtained
SwtLightControlif the given widget has an associated SWT light wrapper,nullotherwise.
-
getHostSwtLightControl
Obtains the hostingSwtLightCompositefor the given SWT widget.- Parameters:
widget- SWT widget to obtain the hosting composite of.- Returns:
SwtLightCompositeif widget is hosted inside one,nullotherwise.
-
containsWidget
Checks whether a light control contains an SWT widget.- Parameters:
control- the light control tested for containing a given SWT widgetwidget- the SWT widget tested for being contained in a given light control- Returns:
trueifcontrolcontains the givenwidget
-
getHostDisplay
Obtains the hostingDisplayfor the given control.- Parameters:
control- the control to obtain the display for, should not benull.- Returns:
- the hosting display, never
null.
-
getSwtControl
public org.eclipse.swt.widgets.Control getSwtControl()Gets the associated native SWT control.- Returns:
- the SWT control.
-
getOverlaySource
Gets the overlay source if this control is an overlay. Overlay is a special kind of theSwtLightControls, overlays do not participate in layouting process. Overlays used to provide the native SWT controls for the needs of the light controls. For example, the editing support of theLightTextis implemented via the overlays.- Returns:
- the source control of this overlay,
nullif this control is not an overlay.
-
setOverlaySource
Sets the overlay source.- Parameters:
control- the new overlay source.- See Also:
-
getParent
Description copied from interface:ILightControlGets the parent of this control.- Specified by:
getParentin interfaceILightControl- Returns:
- the parent composite control or
nullif this control is not contained in any composite.
-
setParent
Description copied from interface:ILightControlSets the parent of this control.- Specified by:
setParentin interfaceILightControl- Parameters:
parent- the new parent.
-
getBounds
public org.eclipse.swt.graphics.Rectangle getBounds()Description copied from interface:ILightControlGets the bounds of this control.- Specified by:
getBoundsin interfaceILightControl- Returns:
- the bounds.
-
setBounds
public void setBounds(org.eclipse.swt.graphics.Rectangle bounds) Description copied from interface:ILightControlSets the bounds of this control.- Specified by:
setBoundsin interfaceILightControl- Parameters:
bounds- the new bounds.
-
getVisibleBounds
public org.eclipse.swt.graphics.Rectangle getVisibleBounds()- Specified by:
getVisibleBoundsin interfaceILightControl
-
invalidate
public void invalidate()Description copied from interface:ILightControlInvalidates the bounds of this control.- Specified by:
invalidatein interfaceILightControl
-
invalidate
public void invalidate(org.eclipse.swt.graphics.Rectangle rectangle) Description copied from interface:ILightControlInvalidates the given rectangle of this control.- Specified by:
invalidatein interfaceILightControl- Parameters:
rectangle- the rectangle to invalidate.
-
setFocus
Description copied from interface:ILightControlSets the focus to this control.- Specified by:
setFocusin interfaceILightControl- Parameters:
focusSource- the focus request source.- Returns:
trueif focus was set,falseotherwise.
-
isFocused
public boolean isFocused()Description copied from interface:ILightControlChecks if this control is focused.- Specified by:
isFocusedin interfaceILightControl- Returns:
trueif this control is focused,falseotherwise.
-
handleEvent
public void handleEvent(org.eclipse.swt.widgets.Event event) Description copied from interface:ILightControlHandles the SWT event, SWT events are pumped to this method if this control is active.- Specified by:
handleEventin interfaceILightControl- Parameters:
event- the event to handle.- See Also:
-
isDisposed
public boolean isDisposed()Description copied from interface:ILightControlChecks if control this is disposed.- Specified by:
isDisposedin interfaceILightControl- Returns:
trueif this control is disposed,falseotherwise.
-
dispose
public void dispose()Description copied from interface:ILightControlDisposes this control.- Specified by:
disposein interfaceILightControl
-
paint
public void paint(org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle rectangle) Description copied from interface:ILightControlPaints the given rectangle of this control.- Specified by:
paintin interfaceILightControl- Parameters:
gc- theGCto paint on.rectangle- the rectangle to paint.
-
isVisible
public boolean isVisible()Description copied from interface:ILightControlChecks if this control is visible.- Specified by:
isVisiblein interfaceILightControl- Returns:
trueif this control is visible,falseif not.
-
setVisible
public void setVisible(boolean value) Description copied from interface:ILightControlSets this control visibility.- Specified by:
setVisiblein interfaceILightControl- Parameters:
value- the new visibility value.
-
isEnabled
public boolean isEnabled()Description copied from interface:ILightControlChecks if this is enabled.- Specified by:
isEnabledin interfaceILightControl- Returns:
trueif this control is enabled,falseif not.
-
setEnabled
public void setEnabled(boolean enabled) Description copied from interface:ILightControlSets this control enablement.- Specified by:
setEnabledin interfaceILightControl
-
computeSize
public org.eclipse.swt.graphics.Point computeSize(org.eclipse.swt.graphics.GC gc, int width, int height, boolean flushCache) Description copied from interface:ILightControlComputes the size of this control.- Specified by:
computeSizein interfaceILightControl- Parameters:
gc- the GC to do measurements with.width- the width hint,SWT.DEFAULTto compute the preferred width.height- the height hint,SWT.DEFAULTto compute the preferred height.flushCache- the flush cache flag, instructs the associated layout to reset all its caches, if any.- Returns:
- the computed size.
-
getLayoutData
Description copied from interface:ILightControlGets the layout data of this control.- Specified by:
getLayoutDatain interfaceILightControl- Returns:
- the layout data.
-
setLayoutData
Description copied from interface:ILightControlSets the layout data of this control.- Specified by:
setLayoutDatain interfaceILightControl- Parameters:
layoutData- the new layout data.
-
getData
Description copied from interface:ILightControlGets the user defined data associated with this control.- Specified by:
getDatain interfaceILightControl- Parameters:
key- the key.- Returns:
- the data or
nullif no data was set for the given key.
-
setData
Description copied from interface:ILightControlSets the user-defined data associated with this control.- Specified by:
setDatain interfaceILightControl- Parameters:
key- the key.data- the data.
-
getCursor
public org.eclipse.swt.graphics.Cursor getCursor()Description copied from interface:ILightControlGets the cursor of this control.- Specified by:
getCursorin interfaceILightControl- Returns:
- the cursor or
nullif no cursor was set.
-
setCursor
public void setCursor(org.eclipse.swt.graphics.Cursor cursor) Description copied from interface:ILightControlSets the cursor of this control.- Specified by:
setCursorin interfaceILightControl- Parameters:
cursor- the new cursor ornullto reset to default cursor.
-
getTooltip
Description copied from interface:ILightControlGets the tooltip of this control.- Specified by:
getTooltipin interfaceILightControl- Returns:
- the tooltip or
nullif no tooltip was set.
-
setTooltip
Description copied from interface:ILightControlSets the tooltip of this control.- Specified by:
setTooltipin interfaceILightControl- Parameters:
tooltip- the new tooltip ornullto clear the tooltip.
-
addControlListener
Description copied from interface:ILightControlAdds the control listener.- Specified by:
addControlListenerin interfaceILightControl- Parameters:
listener- the listener.
-
removeControlListener
Description copied from interface:ILightControlRemoves the control listener.- Specified by:
removeControlListenerin interfaceILightControl- Parameters:
listener- the listener.
-
disposed
protected void disposed()Invoked when the control is disposed from the SWT side. In other words, the native SWT control is disposed at this point and we do not need to dispose it again. Override this method to customize the detaching logic, it is a good place to remove listeners from the native SWT control and stuff like that.
-