Class LookAndFeel
- Direct Known Subclasses:
DefaultLookAndFeel
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidEvery component binds itself to the look and feel thus allowing the look and feel to customize the component.abstract TextSelection.SpancalculateLabelSpan(TextSelection sel, Label l) Calculates the text selection spans for a given labelabstract TextSelection.SpanscalculateTextAreaSpan(TextSelection sel, TextArea ta) Calculates the Spans used in text selection for a given text area.abstract TextSelection.SpanscalculateTextFieldSpan(TextSelection sel, TextArea ta) Calculates the Spans used in text selection for a given text field.abstract voiddrawButton(Graphics g, Button b) Invoked for drawing a button widgetabstract voiddrawCheckBox(Graphics g, Button cb) Invoked for drawing a checkbox widgetabstract voiddrawComboBox(Graphics g, List cb) Invoked for drawing a combo box widgetvoiddrawHorizontalScroll(Graphics g, Component c, float offsetRatio, float blockSizeRatio) Draws a horizontal scroll bar in the given componentabstract voidInvoked for drawing a label widgetabstract voidInvoked for drawing a list widgetabstract voiddrawPullToRefresh(Graphics g, Component cmp, boolean taskExecuted) Paints the pull to refreshabstract voiddrawRadioButton(Graphics g, Button rb) Invoked for drawing the radio button widgetabstract voiddrawTextArea(Graphics g, TextArea ta) Draw the given text areaabstract voiddrawTextField(Graphics g, TextArea ta) Draws the text field without its cursor which is drawn in a separate method input mode indication can also be drawn using this method.abstract voiddrawTextFieldCursor(Graphics g, TextArea ta) Draws the cursor of the text field, blinking is handled simply by avoiding a call to this method.voiddrawVerticalScroll(Graphics g, Component c, float offsetRatio, float blockSizeRatio) Draws a vertical scroll bar in the given componentabstract DimensionCalculate the preferred size of the componentabstract DimensionCalculate the preferred size of the componentabstract DimensionCalculate the preferred size of the componentAllows us to define a default animation that will draw the transition for entering a dialogAllows us to define a default animation that will draw the transition for exiting a dialogintTint color is set when a form is partially covered be it by a menu or by a dialog.Allows us to define a default animation that will draw the transition for entering a formAllows us to define a default animation that will draw the transition for exiting a formAllows us to define a default animation that will draw the transition for entering a MenuAllows us to define a default animation that will draw the transition for exiting a MenuintIndicates the default speed for smooth scrollingintThis color is used to paint disable mode text color.intReturns
intIndicates the width/height of the fading edge to indicate scrollingintReturns the default height of a horizontal scroll barabstract DimensionCalculate the preferred size of the componentabstract DimensionCalculate the preferred size of the componentThis method returns the MenuBar class.Image[]Simple getter for the menu iconsReturns the Menu default rendererabstract intReturns the required height of the pull to refresh featureabstract DimensionCalculate the preferred size of the componentintAllows defining a tactile touch device that vibrates when the user presses a component that should respond with tactile feedback on a touch device (e.g. vibrate).abstract DimensiongetTextAreaSize(TextArea ta, boolean pref) Calculate the preferred size of the componentintThe color of the text field cursorabstract DimensionCalculate the preferred size of the componentlongGets the ticker speedintReturns the default width of a vertical scroll barbooleanIndicates if the bg image of a style should determine the minimum preferred size according to the themebooleanEnable the tensile drag to work even when a component doesn't have a scroll showable (scrollable flag still needs to be set to true)booleanIndicates whether labels should end with 3 points by defaultbooleanIndicates whether lists and containers should have smooth scrolling by defaultbooleanIndicates whether scrolling this component should jump to a specific location in a gridbooleanIndicates whether tensile drag should be active by defaultbooleanIndicates whether tensile highlight should be active by defaultbooleanIndicates whether the scrollbar should fade when unusedbooleanIndicates whether the edge of a scrollable area should fade outbooleanIndicates whether lists and containers should scroll only via focus and thus "jump" when moving to a larger component as was the case in older versions of Codename One.booleanIndicates whether softbuttons should be reversed from their default orientationbooleanisRTL()Use this to check if the LookAndFeel is in RTL modebooleanReturns
booleanIndicates whether the menu UI should target a touch based device or a standard cell phonevoidpaintTensileHighlight(Component t, Graphics g, boolean top, int opacity) Paints the tensile hightlight imagevoidrefreshTheme(boolean completeClear) This method is a callback to the LookAndFeel when a theme is being changed in the UIManagervoidsetBackgroundImageDetermineSize(boolean backgroundImageDetermineSize) Indicates if the bg image of a style should determine the minimum preferred size according to the themevoidsetDefaultAlwaysTensile(boolean defaultAlwaysTensile) Enable the tensile drag to work even when a component doesn't have a scroll showable (scrollable flag still needs to be set to true)voidsetDefaultDialogTransitionIn(Transition defaultDialogTransitionIn) Allows us to define a default animation that will draw the transition for entering a dialogvoidsetDefaultDialogTransitionOut(Transition defaultDialogTransitionOut) Allows us to define a default animation that will draw the transition for exiting a dialogvoidsetDefaultEndsWith3Points(boolean defaultEndsWith3Points) Indicates whether labels should end with 3 points by defaultvoidsetDefaultFormTintColor(int defaultFormTintColor) Tint color is set when a form is partially covered be it by a menu or by a dialog.voidsetDefaultFormTransitionIn(Transition defaultFormTransitionIn) Allows us to define a default animation that will draw the transition for entering a formvoidsetDefaultFormTransitionOut(Transition defaultFormTransitionOut) Allows us to define a default animation that will draw the transition for exiting a formvoidsetDefaultMenuTransitionIn(Transition defaultMenuTransitionIn) Allows us to define a default animation that will draw the transition for entering a MenuvoidsetDefaultMenuTransitionOut(Transition defaultMenuTransitionOut) Allows us to define a default animation that will draw the transition for exiting a MenuvoidsetDefaultSmoothScrolling(boolean defaultSmoothScrolling) Indicates whether lists and containers should have smooth scrolling by defaultvoidsetDefaultSmoothScrollingSpeed(int defaultSmoothScrollingSpeed) Indicates the default speed for smooth scrollingvoidsetDefaultSnapToGrid(boolean defaultSnapToGrid) Indicates whether scrolling this component should jump to a specific location in a gridvoidsetDefaultTensileDrag(boolean defaultTensileDrag) Indicates whether tensile drag should be active by defaultvoidsetDisableColor(int disableColor) Simple setter to disable colorvoidsetFadeScrollBar(boolean fadeScrollBar) Indicates whether the scrollbar should fade when unusedvoidsetFadeScrollBarSpeed(int fadeScrollBarSpeed) Parameters
voidsetFadeScrollEdge(boolean fadeScrollEdge) Indicates whether the edge of a scrollable area should fade outvoidsetFadeScrollEdgeLength(int fadeScrollEdgeLength) Indicates the width/height of the fading edge to indicate scrollingvoidSets the foreground color and font for a generic component, reuse-able by most component drawing codevoidsetFocusScrolling(boolean focusScrolling) Indicates whether lists and containers should scroll only via focus and thus "jump" when moving to a larger component as was the case in older versions of Codename One.voidsetMenuBarClass(Class menuBar) Simple setter for the MenuBar ClassvoidsetMenuIcons(Image select, Image cancel, Image menu) Sets globally the Menu iconsvoidsetMenuRenderer(ListCellRenderer menuRenderer) Sets the Menu default renderervoidsetReverseSoftButtons(boolean reverseSoftButtons) Indicates whether softbuttons should be reversed from their default orientationvoidsetRTL(boolean rtl) Sets this LookAndFeel to operate in right-to-left mode.voidsetTactileTouchDuration(int tactileTouchDuration) Allows defining a tactile touch device that vibrates when the user presses a component that should respond with tactile feedback on a touch device (e.g. vibrate).voidsetTextFieldCursorColor(int textFieldCursorColor) The color of the text field cursorvoidsetTickerSpeed(long tickerSpeed) Sets the ticker speedvoidsetTouchMenus(boolean touchMenus) Indicates whether the menu UI should target a touch based device or a standard cell phonevoidInvoked when a look and feel is removed, allows a look and feel to release resources related to binding components.
-
Constructor Details
-
LookAndFeel
-
-
Method Details
-
bind
Every component binds itself to the look and feel thus allowing the look and feel to customize the component. Binding occurs at the end of the constructor when the component is in a valid state and ready to be used. Notice that a component might be bound twice or more and it is the responsibility of the LookAndFeel to protect against that.
Parameters
cmp: component instance that may be customized by the look and feel
-
uninstall
public void uninstall()Invoked when a look and feel is removed, allows a look and feel to release resources related to binding components.
See also
- #bind(Component)
-
drawButton
-
drawCheckBox
-
drawComboBox
-
drawLabel
-
calculateLabelSpan
Calculates the text selection spans for a given label
Parameters
-
sel: TextSelection instance -
l: Label
Returns
A span representing the positions of characters in the label
Since
7.0
See also
- TextSelection
-
-
drawList
-
drawRadioButton
-
drawTextArea
-
calculateTextAreaSpan
Calculates the Spans used in text selection for a given text area.
Parameters
-
sel: The current TextSelection instance. -
ta: The TextArea to calculate spans for.
Returns
The spans for the given text field.
Since
7.0
-
-
drawTextField
-
calculateTextFieldSpan
Calculates the Spans used in text selection for a given text field.
Parameters
-
sel: The current TextSelection instance. -
ta: The textfield to calculate spans for.
Returns
The spans for the given text field.
Since
7.0
-
-
drawTextFieldCursor
-
getButtonPreferredSize
-
getCheckBoxPreferredSize
-
getLabelPreferredSize
-
getListPreferredSize
-
getRadioButtonPreferredSize
-
getTextAreaSize
-
getTextFieldPreferredSize
-
getComboBoxPreferredSize
-
drawVerticalScroll
Draws a vertical scroll bar in the given component
Parameters
-
g: graphics context -
c: component to draw on -
offsetRatio: ratio of the scroll bar from 0 to 1 -
blockSizeRatio: block size for the scroll from 0 to 1
-
-
drawHorizontalScroll
Draws a horizontal scroll bar in the given component
Parameters
-
g: graphics context -
c: component to draw on -
offsetRatio: ratio of the scroll bar from 0 to 1 -
blockSizeRatio: block size for the scroll from 0 to 1
-
-
setFG
-
getVerticalScrollWidth
public int getVerticalScrollWidth()Returns the default width of a vertical scroll bar
Returns
default width of a vertical scroll bar
-
getHorizontalScrollHeight
public int getHorizontalScrollHeight()Returns the default height of a horizontal scroll bar
Returns
default height of a horizontal scroll bar
-
getDefaultFormTransitionIn
Allows us to define a default animation that will draw the transition for entering a form
Returns
default transition
-
setDefaultFormTransitionIn
Allows us to define a default animation that will draw the transition for entering a form
Parameters
defaultFormTransitionIn: the default transition
-
getDefaultFormTransitionOut
Allows us to define a default animation that will draw the transition for exiting a form
Returns
default transition
-
setDefaultFormTransitionOut
Allows us to define a default animation that will draw the transition for exiting a form
Parameters
defaultFormTransitionOut: the default transition
-
getDefaultMenuTransitionIn
Allows us to define a default animation that will draw the transition for entering a Menu
Returns
default transition
-
setDefaultMenuTransitionIn
Allows us to define a default animation that will draw the transition for entering a Menu
Parameters
defaultMenuTransitionIn: the default transition
-
getDefaultMenuTransitionOut
Allows us to define a default animation that will draw the transition for exiting a Menu
Returns
default transition
-
setDefaultMenuTransitionOut
Allows us to define a default animation that will draw the transition for exiting a Menu
Parameters
defaultMenuTransitionOut: the default transition
-
getDefaultDialogTransitionIn
Allows us to define a default animation that will draw the transition for entering a dialog
Returns
default transition
-
setDefaultDialogTransitionIn
Allows us to define a default animation that will draw the transition for entering a dialog
Parameters
defaultDialogTransitionIn: the default transition
-
getDefaultDialogTransitionOut
Allows us to define a default animation that will draw the transition for exiting a dialog
Returns
default transition
-
setDefaultDialogTransitionOut
Allows us to define a default animation that will draw the transition for exiting a dialog
Parameters
defaultDialogTransitionOut: the default transition
-
getDefaultFormTintColor
public int getDefaultFormTintColor()Tint color is set when a form is partially covered be it by a menu or by a dialog. A look and feel can override this default value.
Returns
default tint color
-
setDefaultFormTintColor
public void setDefaultFormTintColor(int defaultFormTintColor) Tint color is set when a form is partially covered be it by a menu or by a dialog. A look and feel can override this default value.
Parameters
defaultFormTintColor: the default tint color
-
getDisableColor
public int getDisableColor()This color is used to paint disable mode text color.
Returns
the color value
-
setDisableColor
public void setDisableColor(int disableColor) Simple setter to disable color
Parameters
disableColor: the disable color value
-
isDefaultSmoothScrolling
public boolean isDefaultSmoothScrolling()Indicates whether lists and containers should have smooth scrolling by default
Returns
true if smooth scrolling should be on by default
-
setDefaultSmoothScrolling
public void setDefaultSmoothScrolling(boolean defaultSmoothScrolling) Indicates whether lists and containers should have smooth scrolling by default
Parameters
defaultSmoothScrolling: true if smooth scrolling should be on by default
-
getDefaultSmoothScrollingSpeed
public int getDefaultSmoothScrollingSpeed()Indicates the default speed for smooth scrolling
Returns
speed for smooth scrollin
-
setDefaultSmoothScrollingSpeed
public void setDefaultSmoothScrollingSpeed(int defaultSmoothScrollingSpeed) Indicates the default speed for smooth scrolling
Parameters
defaultSmoothScrollingSpeed: speed for smooth scrollin
-
isReverseSoftButtons
public boolean isReverseSoftButtons()Indicates whether softbuttons should be reversed from their default orientation
Returns
true if softbuttons should be reversed
-
setReverseSoftButtons
public void setReverseSoftButtons(boolean reverseSoftButtons) Indicates whether softbuttons should be reversed from their default orientation
Parameters
reverseSoftButtons: true if softbuttons should be reversed
-
getMenuBarClass
This method returns the MenuBar class.
Returns
the MenuBar class.
Deprecated
-
setMenuBarClass
Simple setter for the MenuBar Class
Parameters
menuBar
Deprecated
-
getMenuRenderer
Returns the Menu default renderer
Returns
default renderer for the menu
-
setMenuRenderer
Sets the Menu default renderer
Parameters
menuRenderer: default renderer for the menu
-
setMenuIcons
-
getMenuIcons
Simple getter for the menu icons
Returns
- Returns:
- an Image array at size of 3, where the first is the select image the second is the cancel image and the last is the menu image.
-
getTickerSpeed
public long getTickerSpeed()Gets the ticker speed
Returns
ticker speed in milliseconds
-
setTickerSpeed
public void setTickerSpeed(long tickerSpeed) Sets the ticker speed
Parameters
tickerSpeed: the speed in milliseconds
-
refreshTheme
public void refreshTheme(boolean completeClear) This method is a callback to the LookAndFeel when a theme is being changed in the UIManager
Parameters
completeClear: indicates that the theme is set and not added
-
isTouchMenus
public boolean isTouchMenus()Indicates whether the menu UI should target a touch based device or a standard cell phone
Returns
true for touch menus
Deprecated
use Display.getCommandBehavior() == Display.COMMAND_BEHAVIOR_TOUCH_MENU
-
setTouchMenus
public void setTouchMenus(boolean touchMenus) Indicates whether the menu UI should target a touch based device or a standard cell phone
Parameters
touchMenus: true to enable touch menus false to disable
Deprecated
use Display.setCommandBehavior(Display.COMMAND_BEHAVIOR_TOUCH_MENU)
-
isRTL
public boolean isRTL()Use this to check if the LookAndFeel is in RTL mode
Returns
true if the LookAndFeel is in right-to-left mode, false otherwise
-
setRTL
public void setRTL(boolean rtl) Sets this LookAndFeel to operate in right-to-left mode.
Parameters
rtl: - true if right-to-left, false if left-to-right
-
getTactileTouchDuration
public int getTactileTouchDuration()Allows defining a tactile touch device that vibrates when the user presses a component that should respond with tactile feedback on a touch device (e.g. vibrate). Setting this to 0 disables tactile feedback completely
Returns
the tactileTouchDuration
-
setTactileTouchDuration
public void setTactileTouchDuration(int tactileTouchDuration) Allows defining a tactile touch device that vibrates when the user presses a component that should respond with tactile feedback on a touch device (e.g. vibrate). Setting this to 0 disables tactile feedback completely
Parameters
tactileTouchDuration: the duration of vibration
-
isDefaultEndsWith3Points
public boolean isDefaultEndsWith3Points()Indicates whether labels should end with 3 points by default
Returns
whether labels should end with 3 points by default
-
setDefaultEndsWith3Points
public void setDefaultEndsWith3Points(boolean defaultEndsWith3Points) Indicates whether labels should end with 3 points by default
Parameters
defaultEndsWith3Points: True to indicates that labels should end with 3 points by default
-
isDefaultTensileDrag
public boolean isDefaultTensileDrag()Indicates whether tensile drag should be active by default
Returns
whether tensile drag should be active by default
-
setDefaultTensileDrag
public void setDefaultTensileDrag(boolean defaultTensileDrag) Indicates whether tensile drag should be active by default
Parameters
defaultTensileDrag: true if tensile drag should be active by default
-
isFocusScrolling
public boolean isFocusScrolling()Indicates whether lists and containers should scroll only via focus and thus "jump" when moving to a larger component as was the case in older versions of Codename One.
Returns
true if focus scrolling is enabled
-
setFocusScrolling
public void setFocusScrolling(boolean focusScrolling) Indicates whether lists and containers should scroll only via focus and thus "jump" when moving to a larger component as was the case in older versions of Codename One.
Parameters
focusScrolling: true to enable focus scrolling
-
isFadeScrollEdge
public boolean isFadeScrollEdge()Indicates whether the edge of a scrollable area should fade out
Returns
the fadeScrollEdge
-
setFadeScrollEdge
public void setFadeScrollEdge(boolean fadeScrollEdge) Indicates whether the edge of a scrollable area should fade out
Parameters
fadeScrollEdge: the fadeScrollEdge to set
-
isFadeScrollBar
public boolean isFadeScrollBar()Indicates whether the scrollbar should fade when unused
Returns
the fadeScrollBar
-
setFadeScrollBar
public void setFadeScrollBar(boolean fadeScrollBar) Indicates whether the scrollbar should fade when unused
Parameters
fadeScrollBar: the fadeScrollBar to set
-
getFadeScrollEdgeLength
public int getFadeScrollEdgeLength()Indicates the width/height of the fading edge to indicate scrolling
Returns
the fadeScrollEdgeLength
-
setFadeScrollEdgeLength
public void setFadeScrollEdgeLength(int fadeScrollEdgeLength) Indicates the width/height of the fading edge to indicate scrolling
Parameters
fadeScrollEdgeLength: the fadeScrollEdgeLength to set
-
getTextFieldCursorColor
public int getTextFieldCursorColor()The color of the text field cursor
Returns
the textFieldCursorColor
-
setTextFieldCursorColor
public void setTextFieldCursorColor(int textFieldCursorColor) The color of the text field cursor
Parameters
textFieldCursorColor: the textFieldCursorColor to set
-
isDefaultSnapToGrid
public boolean isDefaultSnapToGrid()Indicates whether scrolling this component should jump to a specific location in a grid
Returns
the defaultSnapToGrid
-
setDefaultSnapToGrid
public void setDefaultSnapToGrid(boolean defaultSnapToGrid) Indicates whether scrolling this component should jump to a specific location in a grid
Parameters
defaultSnapToGrid: the defaultSnapToGrid to set
-
isDefaultAlwaysTensile
public boolean isDefaultAlwaysTensile()Enable the tensile drag to work even when a component doesn't have a scroll showable (scrollable flag still needs to be set to true)
Returns
the defaultAlwaysTensile
-
setDefaultAlwaysTensile
public void setDefaultAlwaysTensile(boolean defaultAlwaysTensile) Enable the tensile drag to work even when a component doesn't have a scroll showable (scrollable flag still needs to be set to true)
Parameters
defaultAlwaysTensile: the defaultAlwaysTensile to set
-
isDefaultTensileHighlight
public boolean isDefaultTensileHighlight()Indicates whether tensile highlight should be active by default
Returns
the defaultTensileHighlight
-
paintTensileHighlight
-
getFadeScrollBarSpeed
public int getFadeScrollBarSpeed()Returns
the fadeScrollBarSpeed
-
setFadeScrollBarSpeed
public void setFadeScrollBarSpeed(int fadeScrollBarSpeed) Parameters
fadeScrollBarSpeed: the fadeScrollBarSpeed to set
-
isScrollVisible
public boolean isScrollVisible()Returns
scrollVisible
-
isBackgroundImageDetermineSize
public boolean isBackgroundImageDetermineSize()Indicates if the bg image of a style should determine the minimum preferred size according to the theme
Returns
the backgroundImageDetermineSize
-
setBackgroundImageDetermineSize
public void setBackgroundImageDetermineSize(boolean backgroundImageDetermineSize) Indicates if the bg image of a style should determine the minimum preferred size according to the theme
Parameters
backgroundImageDetermineSize: the backgroundImageDetermineSize to set
-
drawPullToRefresh
-
getPullToRefreshHeight
public abstract int getPullToRefreshHeight()Returns the required height of the pull to refresh feature
-