public class SwitchBox extends Box
The size of a switch box is dependent on the font size.
This example shows simple switch boxes (one checked, the other not):
SwitchBox switchBox = new SwitchBox(); switchBox.setChecked(true); SwitchBox switchBox2 = new SwitchBox();
This example shows a styled switche box:
SwitchBox switchBox = new SwitchBox(); switchBox.setChecked(true); SwitchBox switchBox2 = new SwitchBox(); Stylesheet stylesheet = StyleHelper.getStylesheet(); EditableStyle switchBoxStyle = new EditableStyle(); switchBoxStyle.setBorder(new SimpleRoundedBorder(Integer.MAX_VALUE, 2)); switchBoxStyle.setForegroundColor(Colors.BLUE); switchBoxStyle.setPadding(new ComplexOutline(4, 20, 4, 4)); switchBoxStyle.setAlignment(GraphicsContext.LEFT | GraphicsContext.VCENTER); stylesheet.addRule(new TypeSelector(SwitchBox.class), switchBoxStyle); EditableStyle checkedSwitchboxStyle = new EditableStyle(); checkedSwitchboxStyle.setBorderColor(Colors.BLUE); checkedSwitchboxStyle.setPadding(new ComplexOutline(4, 4, 4, 20)); checkedSwitchboxStyle.setAlignment(GraphicsContext.RIGHT | GraphicsContext.VCENTER); stylesheet.addRule(new AndCombinator(new TypeSelector(SwitchBox.class), new StateSelector(State.Checked)), checkedSwitchboxStyle);
EMPTY_ELEMENT_ARRAY
Constructor and Description |
---|
SwitchBox() |
Modifier and Type | Method and Description |
---|---|
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.
|
Rectangle |
validateContent(Style style,
Rectangle availableSize)
Gets the content size of the renderable without the border, margin and padding specified in the style.
|
isChecked, isInState, setChecked, setPressed, updateState
addClassSelector, contains, gainFocus, getAttribute, getChild, getChildrenCount, getChildrenElements, getContentBounds, getParentElement, getStyle, hasClassSelector, isTransparent, lostFocus, mergeStyle, removeAllClassSelectors, removeClassSelector, removeInstanceStyle, render, setClassSelectors, setEnabled, updateStyle, updateStyleOnly, validate
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
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).
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 Rectangle validateContent(Style style, Rectangle availableSize)
StyledRenderable
style
- the style to use.availableSize
- the bounds available for the content. A width or a height equals to MWT.NONE
means no
constraint on this dimension.