public abstract class StyledComposite extends Composite implements Element, StyledRenderable
EMPTY_ELEMENT_ARRAY
Constructor and Description |
---|
StyledComposite()
Creates a styled composite without class selector.
|
Modifier and Type | Method and Description |
---|---|
protected void |
add(Widget widget)
Adds the specified widget to the end of the list of children of this composite.
|
void |
addClassSelector(java.lang.String classSelector)
Adds a class selector.
|
boolean |
contains(int x,
int y)
Gets whether or not a location (x,y) is in the widget's bounds.
|
void |
gainFocus()
Notifies the widget that it is now the focus owner of its panel.
|
java.lang.String |
getAttribute(java.lang.String attribute)
Gets the value of an attribute.
|
Element |
getChild(int index)
Gets the child element at an index.
|
int |
getChildrenCount()
Gets the number of children of this element.
|
Element[] |
getChildrenElements()
Gets the children elements.
|
Element |
getParentElement()
Gets the parent element.
|
Style |
getStyle()
Gets the current style of the renderable.
|
boolean |
hasClassSelector(java.lang.String classSelector)
Gets whether or not the element has the given class selector.
|
boolean |
isInState(State state)
Gets whether or not the element is in the given state.
|
boolean |
isTransparent()
Gets whether this widget is transparent or not.
|
void |
lostFocus()
Notifies the widget that it is no longer the focus owner of its panel.
|
void |
mergeStyle(Style style)
Merges a style with the style of this renderable.
|
void |
removeAllClassSelectors()
Removes all the class selectors.
|
void |
removeClassSelector(java.lang.String classSelector)
Removes a class selector.
|
void |
removeInstanceStyle()
Removes the style specific to this renderable.
|
void |
render(GraphicsContext g)
Renders the renderable on the given graphics context.
|
void |
renderContent(GraphicsContext g,
Style style,
Rectangle bounds)
Renders the content of the renderable without the border, margin and padding specified in the style.
|
void |
setBounds(int x,
int y,
int width,
int height)
Sets the bounds of this widget.
|
protected abstract void |
setBoundsContent(Rectangle bounds)
Sets the bounds of this widget by taking into account the border, margin and padding specified in the style.
|
void |
setClassSelectors(java.lang.String classSelector)
Sets the class selectors.
|
void |
setEnabled(boolean enabled)
Sets this widget to be enabled or not.
|
protected void |
updateStyle()
Updates the style of the widget.
|
protected boolean |
updateStyleOnly()
Update widget style without repainting it.
|
void |
validate(int widthHint,
int heightHint)
Lays out this composite and all its children.
|
abstract Rectangle |
validateContent(Style style,
Rectangle bounds)
Gets the content size of the renderable without the border, margin and padding specified in the style.
|
getFocus, getFocusIndex, getNext, getWidget, getWidgetAt, getWidgets, getWidgetsCount, handleEvent, hideNotify, iterator, remove, removeAllWidgets, requestFocus, requestFocus, requestFocusFrom, showNotify
getAbsoluteX, getAbsoluteX, getAbsoluteY, getAbsoluteY, getEventHandler, getHeight, getPanel, getParent, getPreferredHeight, getPreferredWidth, getRelativeX, getRelativeY, getWidth, getX, getY, hasFocus, invalidate, isEnabled, isShown, isValid, isVisible, repaint, repaint, revalidate, revalidateSubTree, setEventHandler, setLocation, setPreferredSize, setSize, setVisible
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getEventHandler, getHeight, getWidth, getX, getY, handleEvent, hideNotify, isShown, repaint, repaint, setEventHandler, showNotify
public StyledComposite()
public boolean isTransparent()
Widget
By default, a widget is transparent.
A transparent widget means that it will not repaint ALL the rectangular zone defined by its bounds. Then each
time it needs to be repainted, its parent (recursively if also transparent) will be repainted within the bounds
of the widget.
Each time a non-transparent widget needs to be repainted, it is the only one to be repainted.
isTransparent
in class Widget
true
if this widget is transparent, false
otherwise.Widget.contains(int, int)
public boolean contains(int x, int y)
Widget
The given location is considered here as a relative location to parent.
contains
in class Widget
x
- x coordinate.y
- y coordinate.true
if the (x,y)
location is in widget bounds, false
otherwise.Widget.isTransparent()
public Element[] getChildrenElements()
Element
Returns an empty array if no children.
getChildrenElements
in interface Element
Element.EMPTY_ELEMENT_ARRAY
public Element getChild(int index)
Element
public int getChildrenCount()
Element
getChildrenCount
in interface Element
protected void add(Widget widget) throws java.lang.NullPointerException, java.lang.IllegalArgumentException
If the composite is on a panel hierarchy, it is invalidated.
If the given widget is not an Element
, an IllegalArgumentException
is thrown.
add
in class Composite
widget
- the widget to add.java.lang.IllegalArgumentException
- if the given widget is not an element.java.lang.NullPointerException
- if the specified widget is null
.Element
,
StyledWidget
,
StyledComposite
@Nullable public Element getParentElement()
Element
getParentElement
in interface Element
public void mergeStyle(Style style)
StyledRenderable
Equivalent to StyleHelper.getStylesheet().addRule(new InstanceSelector(renderable), style);
mergeStyle
in interface StyledRenderable
style
- the style to merge.StyledRenderable.removeInstanceStyle()
,
InstanceSelector
public void removeInstanceStyle()
StyledRenderable
Equivalent to StyleHelper.getStylesheet().removeRule(new InstanceSelector(renderable));
removeInstanceStyle
in interface StyledRenderable
StyledRenderable.mergeStyle(Style)
,
InstanceSelector
public Style getStyle()
StyledRenderable
The style is retrieved from the global stylesheet: StyleHelper.getStylesheet().getStyle(renderable);
getStyle
in interface StyledRenderable
Stylesheet.getStyle(ej.style.Element)
protected void updateStyle()
protected boolean updateStyleOnly()
true
if the style of this composite or one of its children style has been updated,
false
otherwise.public void render(GraphicsContext g)
Renderable
render
in interface Renderable
g
- the graphics context to be used to draw the renderable.public void renderContent(GraphicsContext g, Style style, Rectangle bounds)
StyledRenderable
The given graphics context is translated and clipped according to the given bounds (the border, margin and padding are applied on this graphics context before).
renderContent
in interface StyledRenderable
g
- the graphics context where to render the content of the renderable.style
- the style to use.bounds
- the remaining size to render the content.Outline.apply(GraphicsContext, Rectangle)
,
Border.apply(GraphicsContext, Rectangle, int)
,
StyleHelper.renderWithoutContent(GraphicsContext, Rectangle, Style)
public void validate(int widthHint, int heightHint)
Composite
The parameters defines the maximum size available for this composite, or MWT.NONE
if there is no
constraint.
After this call the preferred size will have been established.
validate
in class Composite
widthHint
- the width available for this widget or MWT.NONE
heightHint
- the height available for this widget or MWT.NONE
Widget.isVisible()
,
Widget.setPreferredSize(int, int)
public abstract Rectangle validateContent(Style style, Rectangle bounds)
Lays out the children of this composite.
validateContent
in interface StyledRenderable
style
- the style to use.bounds
- the bounds available for the content. A width or a height equals to MWT.NONE
means no
constraint on this dimension.public void setBounds(int x, int y, int width, int height)
Widget
protected abstract void setBoundsContent(Rectangle bounds)
bounds
- the bounds available for the content.public void setEnabled(boolean enabled)
Widget
Requests a repaint of the widget.
setEnabled
in class Widget
enabled
- true
if this widget is to be enabled, false
otherwise.Widget.repaint()
public boolean hasClassSelector(java.lang.String classSelector)
Element
hasClassSelector
in interface Element
classSelector
- the class selector to check.true
if the element has the given class selector, false
otherwise.public void addClassSelector(java.lang.String classSelector)
StyledRenderable
addClassSelector
in interface StyledRenderable
classSelector
- the class selector to add.public void removeClassSelector(java.lang.String classSelector)
StyledRenderable
removeClassSelector
in interface StyledRenderable
classSelector
- the class selector to remove.public void setClassSelectors(java.lang.String classSelector)
StyledRenderable
The given string is a space separated list of class selectors.
If there is already some class selectors, they are removed.
setClassSelectors
in interface StyledRenderable
classSelector
- the class selectors list to split.public void removeAllClassSelectors()
StyledRenderable
removeAllClassSelectors
in interface StyledRenderable
public void gainFocus()
Widget
The subclasses can override this method to add behavior.
public void lostFocus()
Widget
The subclasses can override this method to add behavior.
public boolean isInState(State state)
Element
@Nullable public java.lang.String getAttribute(java.lang.String attribute)
Element
getAttribute
in interface Element
attribute
- the attribute to search.null
if the attribute does not exist.