public abstract class StyledComposite extends ej.mwt.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(ej.mwt.Widget widget) |
void |
addClassSelector(java.lang.String classSelector)
Adds a class selector.
|
boolean |
contains(int x,
int y) |
void |
gainFocus() |
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() |
void |
lostFocus() |
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(ej.microui.display.GraphicsContext g) |
void |
renderContent(ej.microui.display.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) |
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) |
protected void |
updateStyle()
Updates the style of the widget.
|
protected boolean |
updateStyleOnly()
Update widget style without repainting it.
|
void |
validate(int widthHint,
int heightHint) |
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
public StyledComposite()
public boolean isTransparent()
isTransparent
in class ej.mwt.Widget
public boolean contains(int x, int y)
contains
in class ej.mwt.Widget
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(ej.mwt.Widget widget) throws java.lang.NullPointerException, java.lang.IllegalArgumentException
If the given widget is not an Element
, an IllegalArgumentException
is thrown.
add
in class ej.mwt.Composite
java.lang.IllegalArgumentException
- if the given widget is not an element.java.lang.NullPointerException
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(ej.microui.display.GraphicsContext g)
render
in interface ej.mwt.Renderable
public void renderContent(ej.microui.display.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)
validate
in class ej.mwt.Composite
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)
setBounds
in class ej.mwt.Widget
protected abstract void setBoundsContent(Rectangle bounds)
bounds
- the bounds available for the content.public void setEnabled(boolean enabled)
setEnabled
in class ej.mwt.Widget
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()
gainFocus
in class ej.mwt.Widget
public void lostFocus()
lostFocus
in class ej.mwt.Widget
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.