Package com._1c.g5.lwt.interop
Class SwtLightComposite
- java.lang.Object
-
- com._1c.g5.lwt.interop.SwtLightControl
-
- com._1c.g5.lwt.interop.SwtLightComposite
-
- All Implemented Interfaces:
ILightComposite
,ILightControl
- Direct Known Subclasses:
SwtLightScrolledComposite
public class SwtLightComposite extends SwtLightControl implements ILightComposite
Provides the bridge between the light and native SWT controls. Light controls draws itself on the surface of this composite. Native SWT controls uses this composite as a parent.
-
-
Constructor Summary
Constructors Constructor Description SwtLightComposite(org.eclipse.swt.widgets.Composite swtComposite)
Instantiates a new SWT light composite.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends org.eclipse.swt.widgets.Control>
TaddChild(T swtControl)
Adds the native SWT control to this SWT light composite.<T extends ILightControl>
TaddChild(T control, int index)
Adds the child control to this composite.<T extends ILightControl>
TaddChildAfter(T control, ILightControl sibling)
Adds the child control to this composite after the given sibling.void
addLayerAbove(ILightComposite layer, ILightComposite sibling)
void
addLayerBehind(ILightComposite layer, ILightComposite sibling)
ILightControl
controlFromPoint(int x, int y)
Finds the control under the given point.void
dispose()
Disposes this control.protected void
disposed()
Invoked when the control is disposed from the SWT side.ILightControl
getActiveControl()
Gets the active child control of this composite.int
getChildCount()
Gets the child count.Iterable<ILightControl>
getChildren()
Gets the children.org.eclipse.swt.graphics.Cursor
getCursor()
Gets the cursor of this control.static SwtLightComposite
getHostSwtLightComposite(ILightControl control)
Obtains the hostingSwtLightComposite
for the given light control.Iterable<ILightComposite>
getLayers()
ILightLayout
getLayout()
Gets the layout of this composite.org.eclipse.swt.widgets.Composite
getSwtComposite()
Gets the associated SWT composite.static SwtLightComposite
getSwtLightComposite(org.eclipse.swt.widgets.Widget widget)
Obtains theSwtLightComposite
for a given widget.void
handleEvent(org.eclipse.swt.widgets.Event event)
Handles the SWT event, SWT events are pumped to this method if this control is active.boolean
isDesignMode()
void
layout(org.eclipse.swt.graphics.GC gc)
Layouts this composite using its layout, if any.void
paint(org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle rectangle)
Paints the given rectangle of this control.ILightControl
removeChild(int index)
void
removeChild(ILightControl control)
Removes the child control.void
revealRectangle(org.eclipse.swt.graphics.Rectangle rectangle, boolean partial, boolean recursive)
void
setActiveControl(ILightControl control)
Sets the active control for this composite.void
setBounds(org.eclipse.swt.graphics.Rectangle bounds)
Sets the bounds of this control.void
setCursor(org.eclipse.swt.graphics.Cursor cursor)
Sets the cursor of this control.void
setDesignMode(boolean designMode)
void
setEnabled(boolean enabled)
Sets this control enablement.boolean
setFocus(FocusSource focusSource)
Sets the focus to this control.void
setLayout(ILightLayout layout)
Sets the layout of this composite.org.eclipse.swt.graphics.Point
translatePointFromControl(ILightControl child, org.eclipse.swt.graphics.Point point)
Translate the point in the given child control coordinates to the coordinates of this composite.org.eclipse.swt.graphics.Point
translatePointToControl(ILightControl child, org.eclipse.swt.graphics.Point point)
Translate the point in the coordinates of this composite to the coordinates of the given child control.org.eclipse.swt.graphics.Rectangle
translateRectangleFromControl(ILightControl child, org.eclipse.swt.graphics.Rectangle rectangle)
Translate the rectangle in the given child control coordinates to the coordinates of this composite.org.eclipse.swt.graphics.Rectangle
translateRectangleToControl(ILightControl child, org.eclipse.swt.graphics.Rectangle rectangle)
Translate the rectangle in the coordinates of this composite to the coordinates of the given child control.boolean
traverse(ILightControl control, TraverseDirection direction)
Traverses this composite starting at the given control in the given direction.boolean
traverse(TraverseDirection direction)
Traverses this composite in the given direction.-
Methods inherited from class com._1c.g5.lwt.interop.SwtLightControl
addControlListener, computeSize, containsWidget, getBounds, getData, getHostDisplay, getHostSwtLightControl, getLayoutData, getOverlaySource, getParent, getSwtControl, getSwtLightControl, getTooltip, getVisibleBounds, invalidate, invalidate, isDisposed, isEnabled, isFocused, isVisible, removeControlListener, setData, setLayoutData, setOverlaySource, setParent, setTooltip, setVisible
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com._1c.g5.lwt.ILightComposite
getMainLayer
-
Methods inherited from interface com._1c.g5.lwt.ILightControl
addControlListener, computeSize, getBounds, getData, getLayoutData, getParent, getTooltip, getVisibleBounds, initialize, invalidate, invalidate, isDisposed, isEnabled, isFocused, isVisible, removeControlListener, setData, setLayoutData, setParent, setTooltip, setVisible
-
-
-
-
Method Detail
-
getSwtLightComposite
public static SwtLightComposite getSwtLightComposite(org.eclipse.swt.widgets.Widget widget)
Obtains theSwtLightComposite
for a given widget.- Parameters:
widget
- the widget to obtain composite of.- Returns:
- obtained
SwtLightComposite
if the given widget has an associated SWT light composite,null
otherwise.
-
getHostSwtLightComposite
public static SwtLightComposite getHostSwtLightComposite(ILightControl control)
Obtains the hostingSwtLightComposite
for the given light control.- Parameters:
control
- control to obtain the hosting composite of.- Returns:
SwtLightComposite
if control is hosted inside one,null
otherwise.
-
setDesignMode
public void setDesignMode(boolean designMode)
-
isDesignMode
public boolean isDesignMode()
-
getSwtComposite
public org.eclipse.swt.widgets.Composite getSwtComposite()
Gets the associated SWT composite.- Returns:
- the SWT composite.
-
addChild
public <T extends org.eclipse.swt.widgets.Control> T addChild(T swtControl)
Adds the native SWT control to this SWT light composite.- Parameters:
swtControl
- the SWT control to add.- Returns:
- the added SWT control.
-
setBounds
public void setBounds(org.eclipse.swt.graphics.Rectangle bounds)
Description copied from interface:ILightControl
Sets the bounds of this control.- Specified by:
setBounds
in interfaceILightControl
- Overrides:
setBounds
in classSwtLightControl
- Parameters:
bounds
- the new bounds.
-
setEnabled
public void setEnabled(boolean enabled)
Description copied from interface:ILightControl
Sets this control enablement.- Specified by:
setEnabled
in interfaceILightControl
- Overrides:
setEnabled
in classSwtLightControl
-
getChildCount
public int getChildCount()
Description copied from interface:ILightComposite
Gets the child count.- Specified by:
getChildCount
in interfaceILightComposite
- Returns:
- the number of direct children of this composite.
-
getChildren
public Iterable<ILightControl> getChildren()
Description copied from interface:ILightComposite
Gets the children.- Specified by:
getChildren
in interfaceILightComposite
- Returns:
- the direct children of this composite.
-
addChild
public <T extends ILightControl> T addChild(T control)
Description copied from interface:ILightComposite
Adds the child control to this composite.- Specified by:
addChild
in interfaceILightComposite
- Parameters:
control
- the control to add.- Returns:
- the control added.
-
addChild
public <T extends ILightControl> T addChild(T control, int index)
Description copied from interface:ILightComposite
Adds the child control to this composite.- Specified by:
addChild
in interfaceILightComposite
- Parameters:
control
- the control to add.index
- the index to add the control at.- Returns:
- the control added.
-
addChildAfter
public <T extends ILightControl> T addChildAfter(T control, ILightControl sibling)
Description copied from interface:ILightComposite
Adds the child control to this composite after the given sibling.- Specified by:
addChildAfter
in interfaceILightComposite
- Parameters:
control
- the control to add.sibling
- the sibling to add the control after,null
to prepend the control to the children.- Returns:
- the control added.
-
removeChild
public void removeChild(ILightControl control)
Description copied from interface:ILightComposite
Removes the child control.- Specified by:
removeChild
in interfaceILightComposite
- Parameters:
control
- the control to remove.
-
removeChild
public ILightControl removeChild(int index)
- Specified by:
removeChild
in interfaceILightComposite
-
paint
public void paint(org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle rectangle)
Description copied from interface:ILightControl
Paints the given rectangle of this control.- Specified by:
paint
in interfaceILightControl
- Overrides:
paint
in classSwtLightControl
- Parameters:
gc
- theGC
to paint on.rectangle
- the rectangle to paint.
-
getLayout
public ILightLayout getLayout()
Description copied from interface:ILightComposite
Gets the layout of this composite.- Specified by:
getLayout
in interfaceILightComposite
- Returns:
- the associated layout or
null
if no layout is set.
-
setLayout
public void setLayout(ILightLayout layout)
Description copied from interface:ILightComposite
Sets the layout of this composite.- Specified by:
setLayout
in interfaceILightComposite
- Parameters:
layout
- the new layout.
-
layout
public void layout(org.eclipse.swt.graphics.GC gc)
Description copied from interface:ILightComposite
Layouts this composite using its layout, if any.- Specified by:
layout
in interfaceILightComposite
- Parameters:
gc
- theGC
to do the measurements with.
-
setFocus
public boolean setFocus(FocusSource focusSource)
Description copied from interface:ILightControl
Sets the focus to this control.- Specified by:
setFocus
in interfaceILightControl
- Overrides:
setFocus
in classSwtLightControl
- Parameters:
focusSource
- the focus request source.- Returns:
true
if focus was set,false
otherwise.
-
setActiveControl
public void setActiveControl(ILightControl control)
Description copied from interface:ILightComposite
Sets the active control for this composite. The given control may be the indirect child of this composite. This composite should not try to change the focus as the focus may be already set.- Specified by:
setActiveControl
in interfaceILightComposite
- Parameters:
control
- the new active control.
-
getActiveControl
public ILightControl getActiveControl()
Description copied from interface:ILightComposite
Gets the active child control of this composite.- Specified by:
getActiveControl
in interfaceILightComposite
- Returns:
- the active control.
- See Also:
ILightComposite.setActiveControl(com._1c.g5.lwt.ILightControl)
-
traverse
public boolean traverse(ILightControl control, TraverseDirection direction)
Description copied from interface:ILightComposite
Traverses this composite starting at the given control in the given direction.- Specified by:
traverse
in interfaceILightComposite
- Parameters:
control
- the control to start from.direction
- the direction to traverse in.- Returns:
true
if traversal was successful and the focus was set to one of the child controls,false
otherwise.
-
traverse
public boolean traverse(TraverseDirection direction)
Description copied from interface:ILightComposite
Traverses this composite in the given direction.- Specified by:
traverse
in interfaceILightComposite
- Parameters:
direction
- the direction to traverse in.- Returns:
true
if traversal was successful and the focus was set to one of the child controls,false
otherwise.
-
handleEvent
public void handleEvent(org.eclipse.swt.widgets.Event event)
Description copied from interface:ILightControl
Handles the SWT event, SWT events are pumped to this method if this control is active.- Specified by:
handleEvent
in interfaceILightControl
- Overrides:
handleEvent
in classSwtLightControl
- Parameters:
event
- the event to handle.- See Also:
ILightComposite.setActiveControl(ILightControl)
-
translatePointFromControl
public org.eclipse.swt.graphics.Point translatePointFromControl(ILightControl child, org.eclipse.swt.graphics.Point point)
Description copied from interface:ILightComposite
Translate the point in the given child control coordinates to the coordinates of this composite.- Specified by:
translatePointFromControl
in interfaceILightComposite
- Parameters:
child
- the child control to translate the point from or this composite.point
- the point to translate.- Returns:
- the translated point or
null
if the given child control is neither a child of this composite nor this composite.
-
translateRectangleFromControl
public org.eclipse.swt.graphics.Rectangle translateRectangleFromControl(ILightControl child, org.eclipse.swt.graphics.Rectangle rectangle)
Description copied from interface:ILightComposite
Translate the rectangle in the given child control coordinates to the coordinates of this composite.- Specified by:
translateRectangleFromControl
in interfaceILightComposite
- Parameters:
child
- the child to translate the rectangle from or this composite.rectangle
- the rectangle to translate.- Returns:
- the translated rectangle or
null
if the given child is neither a child of this composite nor this composite.
-
translatePointToControl
public org.eclipse.swt.graphics.Point translatePointToControl(ILightControl child, org.eclipse.swt.graphics.Point point)
Description copied from interface:ILightComposite
Translate the point in the coordinates of this composite to the coordinates of the given child control.- Specified by:
translatePointToControl
in interfaceILightComposite
- Parameters:
child
- the child to translate the point to or this composite.point
- the point to translate.- Returns:
- the translated point or
null
if the given child is neither a child of this composite nor this composite.
-
translateRectangleToControl
public org.eclipse.swt.graphics.Rectangle translateRectangleToControl(ILightControl child, org.eclipse.swt.graphics.Rectangle rectangle)
Description copied from interface:ILightComposite
Translate the rectangle in the coordinates of this composite to the coordinates of the given child control.- Specified by:
translateRectangleToControl
in interfaceILightComposite
- Parameters:
child
- the child to translate the point to or this composite.rectangle
- the rectangle to translate.- Returns:
- the translated rectangle or
null
if the given child is neither a child of this composite nor this composite.
-
controlFromPoint
public ILightControl controlFromPoint(int x, int y)
Description copied from interface:ILightComposite
Finds the control under the given point.- Specified by:
controlFromPoint
in interfaceILightComposite
- Parameters:
x
- the x coordinate of the point.y
- the y coordinate of the point.- Returns:
- found child control, this composite or
null
if nothing found under the point and this composite is transparent for the mouse events.
-
getLayers
public Iterable<ILightComposite> getLayers()
- Specified by:
getLayers
in interfaceILightComposite
-
addLayerAbove
public void addLayerAbove(ILightComposite layer, ILightComposite sibling)
- Specified by:
addLayerAbove
in interfaceILightComposite
-
addLayerBehind
public void addLayerBehind(ILightComposite layer, ILightComposite sibling)
- Specified by:
addLayerBehind
in interfaceILightComposite
-
revealRectangle
public void revealRectangle(org.eclipse.swt.graphics.Rectangle rectangle, boolean partial, boolean recursive)
- Specified by:
revealRectangle
in interfaceILightComposite
-
setCursor
public void setCursor(org.eclipse.swt.graphics.Cursor cursor)
Description copied from interface:ILightControl
Sets the cursor of this control.- Specified by:
setCursor
in interfaceILightControl
- Overrides:
setCursor
in classSwtLightControl
- Parameters:
cursor
- the new cursor ornull
to reset to default cursor.
-
getCursor
public org.eclipse.swt.graphics.Cursor getCursor()
Description copied from interface:ILightControl
Gets the cursor of this control.- Specified by:
getCursor
in interfaceILightControl
- Overrides:
getCursor
in classSwtLightControl
- Returns:
- the cursor or
null
if no cursor was set.
-
dispose
public void dispose()
Description copied from interface:ILightControl
Disposes this control.- Specified by:
dispose
in interfaceILightControl
- Overrides:
dispose
in classSwtLightControl
-
disposed
protected void disposed()
Description copied from class:SwtLightControl
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.- Overrides:
disposed
in classSwtLightControl
-
-