|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.kalmeo.kuix.widget.Widget
public class Widget
This class is the base of all Kuix widgets.
For further informations, visit the Kuix widgets reference page.
Nested Class Summary | |
---|---|
protected class |
Widget.BindInstruction
This class represents a bind instruction for a specific attribute. |
Field Summary | |
---|---|
protected LinkedList |
bindInstructions
|
protected static Alignment |
DEFAULT_ALIGN
|
protected static Alignment[] |
DEFAULT_BACKGROUND_ALIGN
|
protected static Repeat[] |
DEFAULT_BACKGROUND_REPEAT
|
protected static Insets |
DEFAULT_BORDER
|
protected static Gap |
DEFAULT_GAP
|
protected static Insets |
DEFAULT_MARGIN
|
protected static Metrics |
DEFAULT_MIN_SIZE
|
protected static Insets |
DEFAULT_PADDING
|
protected static Span |
DEFAULT_SPAN
|
protected static Weight |
DEFAULT_WEIGHT
|
Widget |
next
|
Widget |
parent
|
Widget |
previous
|
Constructor Summary | |
---|---|
Widget()
Construct a Widget |
|
Widget(java.lang.String tag)
Construct a Widget |
Method Summary | |
---|---|
Widget |
add(Widget widget)
Add a Widget to this as child |
Widget |
add(Widget widget,
Widget referenceWidget,
boolean after)
Add a Widget to this as child before or after
referenceWidget child. |
void |
bringNear(Widget widget,
Widget referenceWidget,
boolean after)
Bring the widget on top or behind
referenceWidget according to the after
parameter. |
void |
bringToFront(Widget widget)
Bring the widget to the front of the orthers. |
void |
catchChildrenFrom(Widget widget)
Catch all child widgets from widget to move them into
this widget. |
void |
cleanUp()
CleanUp all widget's link and propagate the action on its children. |
void |
cleanUpChildren()
CleanUp all children. |
void |
clearCachedStyle(boolean propagateToChildren)
Clear the cachedStyle. |
protected void |
doLayout()
Layout the widget if its layout is defined. |
Alignment |
getAlign()
Returns the alignment value. |
java.lang.Object |
getAttribute(java.lang.String name)
Returns the value of the specified attribute |
Style |
getAuthorStyle()
|
java.lang.String[] |
getAvailablePseudoClasses()
Retuns the list of available pseudo classes. |
Alignment[] |
getBackgroundAlign()
Returns the backroundAlign or alignment list if multi alignments are defined. |
Color |
getBackgroundColor()
Returns the background color value. |
Image[] |
getBackgroundImage()
Returns the backroundImage or image list if multi images are defined. |
Repeat[] |
getBackgroundRepeat()
Returns the backgroundRepeat or repeat list if multi repeats are defined. |
Insets |
getBorder()
|
Alignment[] |
getBorderAlign()
Returns the border alignments array. |
Color[] |
getBorderColor()
Returns the border color array. |
Image[] |
getBorderImage()
Returns the border image array. |
int |
getBorderStroke()
Returns the border stroke int value. |
protected Metrics |
getCachedMetrics()
|
Widget |
getChild()
Returns the first child of this widget. |
Color |
getColor()
Returns the color value. |
DataProvider |
getDataProvider()
Returns the associated DataProvider . |
protected java.lang.Object |
getDefaultStylePropertyValue(java.lang.String name)
Returns the de default style property value for name
property, or null . |
Desktop |
getDesktop()
|
int |
getDisplayX()
Returns the x coordinate of this widget in the display
coordinate system. |
int |
getDisplayY()
Returns the y coordinate of this widget in the display
coordinate system. |
FocusManager |
getFocusManager()
Used for popup like widgets |
Gap |
getGap()
Returns the gap value. |
Color |
getGrayedColor()
Returns the grayedColor. |
int |
getHeight()
|
java.lang.String |
getId()
Returns the id. |
java.lang.String |
getInheritedTag()
Returns the inheritedTag. |
int |
getInnerHeight()
Return the inner height of this widget (exluding margin, border and padding). |
int |
getInnerWidth()
Return the inner width of this widget (exluding margin, border and padding). |
Insets |
getInsets()
|
Widget |
getInternalChildInstance(java.lang.String tag)
Returns the first internal child instance corresponding to the given tag . |
Widget |
getLastChild()
Returns the last child of this widget. |
Layout |
getLayout()
|
LayoutData |
getLayoutData()
|
Insets |
getMargin()
|
Metrics |
getMinSize()
|
Widget |
getOtherFocus(Widget root,
Widget focusedWidget,
Widget nearestFocusableWidget,
boolean forward,
Alignment direction,
boolean checkItself,
boolean checkChild,
boolean checkParent)
Returns the previous or next focusable Widget according to the
forward parameter. |
Insets |
getPadding()
|
Metrics |
getPreferredSize(int preferredWidth)
Returns the prefered size of this Widget |
Span |
getSpan()
Returns the span value. |
java.lang.String[] |
getStyleClasses()
Returns styleClasses. |
protected java.lang.Object |
getStylePropertyValue(java.lang.String name,
boolean inherited)
Return the specified style property value repr�senting by the name , or null . |
protected java.util.Vector |
getStyles()
Returns the list of Style that correspond to this Widget
or null if no style is registered for this widget |
java.lang.String |
getTag()
Returns the tag. |
Weight |
getWeight()
Returns the weight value. |
Widget |
getWidget(java.lang.String id)
Returns the Widget witch correspond to the id , or
null |
Widget |
getWidgetAt(int mx,
int my)
Returns the child widget under mx, my point |
Widget |
getWidgetAt(int mx,
int my,
int x,
int y,
int width,
int height)
Returns the child widget under mx, my point and specify the x, y, width and height of search. |
int |
getWidth()
|
int |
getX()
Returns the x coordinate of this widget in its parent
coordinate system. |
int |
getY()
Returns the y coordinate of this widget in its parent
coordinate system. |
boolean |
hasBindInstruction()
|
boolean |
hasShortcutKeyCodes(byte eventType)
|
boolean |
hasShortcuts()
|
void |
invalidate()
Invalidate the widget's size and position and propagate the information to its parent. |
protected void |
invalidate(Widget fromWidget)
Invalidate the widget's size and position and propagate the information to its parent. |
void |
invalidateAppearance()
Invalidate appearance of full widget's region. |
protected void |
invalidateAppearanceRegion(int x,
int y,
int width,
int height)
Invalidate a specific region. |
void |
invalidateStylePropertiesCache(boolean propagateToChildren)
Invalidate all style properties cache. |
boolean |
isFocusable()
Check if this Widget is focusable. |
boolean |
isFocused()
Check if this Widget is focused. |
boolean |
isFocusWidgetChild()
Check if this Widget is a child of a focused widget. |
boolean |
isIndividualyVisible()
Returns the widget only visibility state. |
boolean |
isInvalidated()
Returns the widget's invalidate status. |
boolean |
isInWidgetTree()
|
boolean |
isObjectAttribute(java.lang.String name)
Check if the given attribute require an Object value. |
boolean |
isPseudoClassCompatible(java.lang.String pseudoClass)
|
boolean |
isShortcutKeyCodeCompatible(int kuixKeyCode,
byte eventType)
Check if a kuixKeyCode is compatible with widget's shortcuts. |
boolean |
isVisible()
Returns the widget's visibility state. |
protected void |
markAsValidate()
Mark this widget as validate |
protected boolean |
needToComputePreferredSize(int preferredWidth)
|
protected void |
onAdded(Widget parent)
Event called when the widjet is added to parent . |
protected void |
onChildAdded(Widget widget)
Event called when the child widjet is added. |
protected void |
onChildRemoved(Widget widget)
Event called when the child widjet is removed. |
protected void |
onFocus(Widget focusedWidget)
Call when the widget or one of its parents gain the focus. |
protected void |
onLostFocus(Widget focusedWidget)
Call when the widget or one of its parents lost the focus. |
protected void |
onRemoved(Widget parent)
Event called when the widjet is removed from parent . |
void |
paint(Graphics g)
Paint the widget itself. |
void |
paintBackground(Graphics g)
Paint the background of this Widget . |
void |
paintBorder(Graphics g)
Paint the widget's border. |
protected void |
paintChildrenImpl(Graphics g)
Invoke the paintImpl method on widget's children. |
void |
paintImpl(Graphics g)
Paint the implementation of the widget (itself and its children). |
protected void |
paintMosaicImage(Graphics g,
Image image,
int x,
int y,
int width,
int height,
Alignment alignment,
int repeatX,
int repeatY)
Paint a cliped zone with mosaic image |
void |
parseAuthorStyle(java.lang.String rawAuthorStyle)
Set new author style by parsing rawAuthorStyle string. |
boolean |
processActionEvent()
Process action event |
boolean |
processDataBindEvent()
|
boolean |
processFocusEvent(byte type)
Process a focus event |
boolean |
processItemsModelUpdateEvent(byte type,
java.lang.String property,
DataProvider item,
LinkedListEnumeration itemsEnumeration)
Process an items model update event. |
boolean |
processKeyEvent(byte type,
int kuixKeyCode)
Process a key event |
boolean |
processModelUpdateEvent(java.lang.String property)
Process a model update event. |
boolean |
processPointerEvent(byte type,
int x,
int y)
Process a pointer event |
boolean |
processShortcutKeyEvent(byte type,
int kuixKeyCode)
Process a shortcut key event |
protected void |
propagateFocusEvent(Widget focusedWidget,
boolean lost)
Propagate focus lost or gain event to widget's children. |
void |
remove()
Remove the current Widget from its parent. |
void |
removeAll()
Remove all childs. |
void |
removeAttributeBindInstruction(java.lang.String attribute)
Remove the bindInstruction for a specific attribute |
void |
requestBackwardFocus()
Requests the focus of the backward focusable Widget . |
void |
requestFocus()
Requests the focus of this Widget . |
void |
requestForwardFocus()
Requests the focus of the forward focusable Widget . |
void |
sendToBack(Widget widget)
Send the widget to the back of the others. |
boolean |
setAttribute(java.lang.String name,
java.lang.String value)
Set the value to the specified attribute representing by
the name |
void |
setAttributeBindInstruction(java.lang.String attribute,
java.lang.String[] properties,
java.lang.String pattern)
Set a BindInstruction for the specified attribute . |
void |
setAuthorStyle(Style authorStyle)
Caution, if widget attribute are already cached, you need to call the invalidateStylePropertiesCache(propagateToChildern) . |
void |
setBounds(int x,
int y,
int width,
int height)
Set the widget's bounds |
void |
setDataProvider(DataProvider dataProvider)
|
void |
setId(java.lang.String id)
Set the id. |
boolean |
setObjectAttribute(java.lang.String name,
java.lang.Object value)
Set the Object value to the specified attribute
representing by the name . |
void |
setShortcutKeyCodes(int shortcutKeyCodes,
byte eventType)
Define the shortcuts key codes intercepted by this widget. |
void |
setShortcuts(java.lang.String rawShortcuts,
byte eventType)
Define the widget's associated shortcuts. |
void |
setStyleClass(java.lang.String styleClass)
|
void |
setStyleClasses(java.lang.String[] styleClasses)
|
void |
setVisible(boolean visible)
Set the widget's visibility state. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final Insets DEFAULT_MARGIN
protected static final Insets DEFAULT_BORDER
protected static final Insets DEFAULT_PADDING
protected static final Metrics DEFAULT_MIN_SIZE
protected static final Gap DEFAULT_GAP
protected static final Span DEFAULT_SPAN
protected static final Weight DEFAULT_WEIGHT
protected static final Alignment DEFAULT_ALIGN
protected static final Alignment[] DEFAULT_BACKGROUND_ALIGN
protected static final Repeat[] DEFAULT_BACKGROUND_REPEAT
public Widget parent
public Widget previous
public Widget next
protected LinkedList bindInstructions
Constructor Detail |
---|
public Widget()
Widget
public Widget(java.lang.String tag)
Widget
tag
- Method Detail |
---|
public Widget getInternalChildInstance(java.lang.String tag)
tag
.
tag
-
public boolean setAttribute(java.lang.String name, java.lang.String value)
value
to the specified attribute representing by
the name
name
- value
-
true
if the attribute existspublic boolean setObjectAttribute(java.lang.String name, java.lang.Object value)
value
to the specified attribute
representing by the name
.
name
- value
-
public boolean isObjectAttribute(java.lang.String name)
name
-
true
if the given attribute require an Object
valuepublic java.lang.Object getAttribute(java.lang.String name)
name
-
public java.lang.String getTag()
public java.lang.String getInheritedTag()
public java.lang.String getId()
public void setId(java.lang.String id)
id
- the id to setpublic java.lang.String[] getStyleClasses()
public void setStyleClasses(java.lang.String[] styleClasses)
styleClasses
- the styleClasses to setpublic void setStyleClass(java.lang.String styleClass)
styleClass
- the styleClass to setpublic java.lang.String[] getAvailablePseudoClasses()
hover
,
selected
, ...).
public boolean isPseudoClassCompatible(java.lang.String pseudoClass)
true
if this widget is compatible with peudo classpublic Widget getChild()
public Widget getLastChild()
public int getX()
x
coordinate of this widget in its parent
coordinate system.
public int getY()
y
coordinate of this widget in its parent
coordinate system.
public int getDisplayX()
x
coordinate of this widget in the display
coordinate system.
public int getDisplayY()
y
coordinate of this widget in the display
coordinate system.
public int getWidth()
public int getHeight()
public int getInnerWidth()
public int getInnerHeight()
public void setBounds(int x, int y, int width, int height)
x
- y
- width
- height
- public Style getAuthorStyle()
public void setAuthorStyle(Style authorStyle)
invalidateStylePropertiesCache(propagateToChildern)
.
authorStyle
- the authorStyle to setpublic void parseAuthorStyle(java.lang.String rawAuthorStyle)
rawAuthorStyle
string.
authorStyle
- the authorStyle to parsepublic boolean isVisible()
false
.
public boolean isIndividualyVisible()
public void setVisible(boolean visible)
visible
- the visible to setpublic boolean isInWidgetTree()
true
if the widget is in widget tree of desktoppublic boolean hasBindInstruction()
true
if one or more data bind instructions are definedpublic void setAttributeBindInstruction(java.lang.String attribute, java.lang.String[] properties, java.lang.String pattern)
attribute
.
attribute
- properties
- pattern
- public void removeAttributeBindInstruction(java.lang.String attribute)
attribute
- public void setShortcuts(java.lang.String rawShortcuts, byte eventType)
kuixKeyCode
and action
, or simply a
kuixKeyCode
. Multiple shortcuts could be assigned to one
widget. This method do not accept directly kuixKeyCode
but
only kuix key representation like left
, *
,
1
.
rawShortcuts
- a string that contains keys and / or action.eventType
- the event type.
KuixConstants.KEY_PRESSED_EVENT_TYPE,
KuixConstants.KEY_REPEATED_EVENT_TYPE or
KuixConstants.KEY_RELEASED_EVENT_TYPE
public void setShortcutKeyCodes(int shortcutKeyCodes, byte eventType)
setShortcut
method.
shortcutKeyCodes
- eventType
- the event type. KuixConstants.KEY_PRESSED_EVENT_TYPE,
KuixConstants.KEY_REPEATED_EVENT_TYPE or
KuixConstants.KEY_RELEASED_EVENT_TYPE
public boolean hasShortcuts()
true
if shortcuts are set for all most one event type.public boolean hasShortcutKeyCodes(byte eventType)
eventType
- the event type. KuixConstants.KEY_PRESSED_EVENT_TYPE,
KuixConstants.KEY_REPEATED_EVENT_TYPE or
KuixConstants.KEY_RELEASED_EVENT_TYPE
true
if shortcuts are set for a specified event
typepublic boolean isShortcutKeyCodeCompatible(int kuixKeyCode, byte eventType)
kuixKeyCode
is compatible with widget's shortcuts.
kuixKeyCode
- eventType
- the event type. KuixConstants.KEY_PRESSED_EVENT_TYPE,
KuixConstants.KEY_REPEATED_EVENT_TYPE or
KuixConstants.KEY_RELEASED_EVENT_TYPE
true
if the given kuixKeyCode
is
compatible with this widget's shortcutspublic DataProvider getDataProvider()
DataProvider
.
public void setDataProvider(DataProvider dataProvider)
dataProvider
- the dataProvider to setpublic Layout getLayout()
public LayoutData getLayoutData()
public Insets getMargin()
public Insets getBorder()
public Insets getPadding()
public Metrics getMinSize()
public Insets getInsets()
public Color getColor()
null
.
public Color[] getBorderColor()
null
.
public int getBorderStroke()
Graphics.SOLID
.
public Image[] getBorderImage()
null
.
public Alignment[] getBorderAlign()
null
.
public Color getBackgroundColor()
null
.
public Image[] getBackgroundImage()
public Alignment[] getBackgroundAlign()
public Repeat[] getBackgroundRepeat()
public Color getGrayedColor()
public Gap getGap()
public Span getSpan()
public Weight getWeight()
public Alignment getAlign()
public Desktop getDesktop()
Desktop
public Widget getWidget(java.lang.String id)
Widget
witch correspond to the id
, or
null
id
-
Widget
witch correspond to the id
public Widget getWidgetAt(int mx, int my)
mx
- my
-
Widget
under mx, my pointpublic Widget getWidgetAt(int mx, int my, int x, int y, int width, int height)
mx
- my
- x
- y
- width
- height
-
Widget
under mx, my pointpublic boolean isFocusable()
Widget
is focusable.
true
if the widget is focusablepublic boolean isFocused()
Widget
is focused.
true
is the widget is focusedpublic boolean isFocusWidgetChild()
Widget
is a child of a focused widget.
true
if this Widget
is a child of a
focused widgetpublic FocusManager getFocusManager()
public Metrics getPreferredSize(int preferredWidth)
Widget
preferredWidth
-
Widget
protected boolean needToComputePreferredSize(int preferredWidth)
preferredWidth
-
true
if the preferredSize computation is neededprotected Metrics getCachedMetrics()
Metrics
public Widget add(Widget widget)
Widget
to this as child
widget
- The Widget
to add
Widget
public Widget add(Widget widget, Widget referenceWidget, boolean after)
Widget
to this as child before or after
referenceWidget
child.
The referenceWidget need to be a child of this widget.
widget
- referenceWidget
- after
-
Widget
public void bringToFront(Widget widget)
widget
to the front of the orthers.
widget
need to be a child of this widget.
widget
- public void sendToBack(Widget widget)
widget
to the back of the others.
widget
need to be a child of this widget.
widget
- public void bringNear(Widget widget, Widget referenceWidget, boolean after)
widget
on top or behind
referenceWidget
according to the after
parameter. widget
need to be a child of this widget.
widget
- referenceWidget
- after
- public void catchChildrenFrom(Widget widget)
widget
to move them into
this
widget.onChildAdd()
,
onAdded()
, onChildRemove()
and
onRemoved()
methods.
widget
- public void remove()
Widget
from its parent.
public void removeAll()
public void cleanUp()
public void cleanUpChildren()
public boolean isInvalidated()
true
if the widget is invalidated.public void invalidate()
doLayout()
and paint() method on all
invalidated widgets.
protected void invalidate(Widget fromWidget)
doLayout()
and paint() method on all
invalidated widgets.
fromWidget
- the Widget responsible of the invalidation.protected void markAsValidate()
protected void doLayout()
public void invalidateAppearance()
protected void invalidateAppearanceRegion(int x, int y, int width, int height)
x
- y
- width
- height
- public void paint(Graphics g)
g
- public void paintBackground(Graphics g)
Widget
.
g
- public void paintBorder(Graphics g)
g
- protected void paintMosaicImage(Graphics g, Image image, int x, int y, int width, int height, Alignment alignment, int repeatX, int repeatY)
g
- image
- x
- y
- width
- height
- alignment
- repeatX
- repeatY
- public void paintImpl(Graphics g)
g
- protected void paintChildrenImpl(Graphics g)
paintImpl
method on widget's children.
g
- protected java.util.Vector getStyles()
Style
that correspond to this Widget
or null
if no style is registered for this widget
Style
that correspond to this Widget
public void clearCachedStyle(boolean propagateToChildren)
propagateToChildren
- public void invalidateStylePropertiesCache(boolean propagateToChildren)
propagateToChildren
- protected java.lang.Object getStylePropertyValue(java.lang.String name, boolean inherited)
name
, or null
.
name
- inherited
- Specify if the property value is inherited from widget's
parent
protected java.lang.Object getDefaultStylePropertyValue(java.lang.String name)
name
property, or null
.
name
-
name
propertypublic void requestFocus()
Widget
.
public void requestBackwardFocus()
Widget
. Starts from this.
public void requestForwardFocus()
Widget
. Starts from this.
public Widget getOtherFocus(Widget root, Widget focusedWidget, Widget nearestFocusableWidget, boolean forward, Alignment direction, boolean checkItself, boolean checkChild, boolean checkParent)
Widget
according to the
forward
parameter.
Widget
public boolean processKeyEvent(byte type, int kuixKeyCode)
type
- kuixKeyCode
-
true
if the event is treated by the widgetpublic boolean processShortcutKeyEvent(byte type, int kuixKeyCode)
type
- kuixKeyCode
-
true
if the event is treated by the widgetpublic boolean processPointerEvent(byte type, int x, int y)
type
- y
- y
-
true
if the event is treated by the widgetpublic boolean processFocusEvent(byte type)
type
-
true
if the event is treated by the widgetpublic boolean processActionEvent()
true
if the event is treated by the widgetpublic boolean processDataBindEvent()
true
if the event is treated by the widgetpublic boolean processModelUpdateEvent(java.lang.String property)
property
-
true
if the event is treated by the widgetpublic boolean processItemsModelUpdateEvent(byte type, java.lang.String property, DataProvider item, LinkedListEnumeration itemsEnumeration)
type
- property
- item
- itemsEnumeration
-
true
if the event is treated by the widgetprotected void propagateFocusEvent(Widget focusedWidget, boolean lost)
focusedWidget
- lost
- protected void onAdded(Widget parent)
widjet
is added to parent
.
protected void onRemoved(Widget parent)
widjet
is removed from parent
.
protected void onChildAdded(Widget widget)
widjet
is added.
widget
- The widget child witch is addedprotected void onChildRemoved(Widget widget)
widjet
is removed.
widget
- The widget child witch is removedprotected void onFocus(Widget focusedWidget)
focusedWidget
- protected void onLostFocus(Widget focusedWidget)
focusedWidget
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |