public abstract class StyledWidget extends Widget implements Element, StyledRenderable
EMPTY_ELEMENT_ARRAY
Modifier | Constructor and Description |
---|---|
protected |
StyledWidget()
Creates a styled widget without class selector.
|
Modifier and Type | Method and Description |
---|---|
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.
|
protected Rectangle |
getContentBounds()
Gets the content bounds of this widget.
|
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 |
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 widget.
|
getAbsoluteX, getAbsoluteX, getAbsoluteY, getAbsoluteY, getEventHandler, getHeight, getPanel, getParent, getPreferredHeight, getPreferredWidth, getRelativeX, getRelativeY, getWidgetAt, getWidth, getX, getY, handleEvent, hasFocus, hideNotify, invalidate, isEnabled, isShown, isValid, isVisible, repaint, repaint, requestFocus, requestFocus, revalidate, revalidateSubTree, setBounds, setEventHandler, setLocation, setPreferredSize, setSize, setVisible, showNotify
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
renderContent, validateContent
getEventHandler, getHeight, getWidth, getX, getY, handleEvent, hideNotify, isShown, repaint, repaint, setEventHandler, showNotify
protected StyledWidget()
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()
@Nullable public Element getParentElement()
Element
getParentElement
in interface Element
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
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 has been updated, false
otherwise.protected Rectangle getContentBounds()
Widget.getWidth()
,
Widget.getHeight()
,
StyleHelper.computeContentBounds(Rectangle, Style)
public void render(GraphicsContext g)
Renderable
render
in interface Renderable
g
- the graphics context to be used to draw the renderable.public void validate(int widthHint, int heightHint)
Widget
After this call the preferred size will have been established.
If the widget is not visible, its preferred size is set to (0, 0)
.
The parameters defines the maximum size available for this widget, or MWT.NONE
if there is no constraint.
validate
in class Widget
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 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.