Package totalcross.ui

Class Ruler


  • public class Ruler
    extends Control
    Ruler is a horizontal or vertical ruler. Here's an example:
     Ruler r = new Ruler();
     r.invert = true;
     add(r, LEFT,AFTER+2);
     
    • Field Detail

      • HORIZONTAL

        public static final int HORIZONTAL
        Defines a HORIZONTAL ruler type.
        See Also:
        Constant Field Values
      • VERTICAL

        public static final int VERTICAL
        Defines a VERTICAL ruler type.
        See Also:
        Constant Field Values
      • invert

        public boolean invert
        Set to true to invert the color of the first and second lines. Only makes sense if 3d is true.
      • dots

        public boolean dots
        Set to true to draw a dotted line instead of a filled line.
    • Constructor Detail

      • Ruler

        public Ruler()
        Constructs a 3d horizonal ruler.
      • Ruler

        public Ruler​(int type,
                     boolean is3d)
        Constructs a ruler of the given type.
        Parameters:
        type - The type of the ruler.
        is3d - Set to false to draw a simple line instead of a 3d one.
        See Also:
        HORIZONTAL, VERTICAL
    • Method Detail

      • getPreferredWidth

        public int getPreferredWidth()
        For horizontal rulers, returns FILL. Otherwise, returns 2 if is 3d or 1 if its not 3d.
        Overrides:
        getPreferredWidth in class Control
      • getPreferredHeight

        public int getPreferredHeight()
        For vertical rulers, returns FILL. Otherwise, returns 2 if is 3d or 1 if its not 3d.
        Overrides:
        getPreferredHeight in class Control
      • onColorsChanged

        public void onColorsChanged​(boolean colorsChanged)
        Description copied from class: Control
        Called after a setEnabled, setForeColor and setBackColor and when a control has been added to a Container. If colorsChanged is true, it was called from setForeColor/setBackColor/Container.add; otherwise, it was called from setEnabled
        Overrides:
        onColorsChanged in class Control
      • onPaint

        public void onPaint​(Graphics g)
        Description copied from class: Control
        Called to draw the control. When this method is called, the graphics object passed has been translated into the coordinate system of the control and the area behind the control has already been painted.
        Overrides:
        onPaint in class Control
        Parameters:
        g - the graphics object for drawing
        See Also:
        Graphics