Package totalcross.ui

Class GridContainer


  • public class GridContainer
    extends Container
    Class that implements a Grid that each cell is a container. See the ImageBook sample, which also shows how to dynamically load and unload images. Here's a piece of it:
     add(gc = new GridContainer(GridContainer.HORIZONTAL_ORIENTATION),LEFT,TOP,FILL,FILL);
       gc.setBackColor(Color.WHITE);
       Flick f = gc.getFlick();
       f.shortestFlick = 1000;
       f.longestFlick = 6000;
       gc.setPageSize(linhas,colunas);
       gc.setRowsPerPage(linhasPorPagina);
       Celula []cels = new Celula[TOTAL_ITEMS];
       for (int i = 0; i < cels.length; i++)
          cels[i] = new Celula(i);
       gc.setCells(cels);
     
    Since:
    TotalCross 1.53
    • Field Detail

      • HORIZONTAL_ORIENTATION

        public static final int HORIZONTAL_ORIENTATION
        Defines a horizontal orientation scroll.
        See Also:
        Constant Field Values
      • VERTICAL_ORIENTATION

        public static final int VERTICAL_ORIENTATION
        Defines a vertical orientation scroll.
        See Also:
        Constant Field Values
      • pagepos

        public NumericPagePosition pagepos
        The container that has the page number and first/last arrows. Only works when orientation is horizontal, and is null otherwise.
      • buttonsHeight

        public int buttonsHeight
        A percentage that defines the heihgt of the arrow buttons. Defaults to 200 in penless devices, 100 otherwise.
    • Method Detail

      • getFlick

        public Flick getFlick()
        Returns the flick attached to the ScrollContainer.
      • onFontChanged

        public void onFontChanged()
        Description copied from class: Control
        Called after a setFont
        Overrides:
        onFontChanged in class Control
      • initUI

        public void initUI()
        Description copied from class: Container
        Called to initialize the User Interface of this container. This differs from the onAddAgain method by that this method is called only once, at the first time the control is added to the parent. When the container is being setup, the initUI method is called; then, the onAddAgain is called every time the container is added again.
        Overrides:
        initUI in class Container
      • setRowsPerPage

        public void setRowsPerPage​(int rpp)
        Sets the rows per page. Changing this value changes the font size dynamically.
      • setPageSize

        public void setPageSize​(int cols,
                                int rows)
        Sets the page size in columns and rows.
      • setCells

        public void setCells​(GridContainer.Cell[] cells)
        Sets the cells of this GridContainer. Note that you cannot delete or add cells, only change the whole set of cells. You must call setRowsPerPage and/or setPageSize before calling this method.
      • onEvent

        public void onEvent​(Event e)
        Description copied from class: Control
        Called to process key, pen, control and other posted events.
        Overrides:
        onEvent in class Control
        Parameters:
        e - the event to process
        See Also:
        Event, KeyEvent, PenEvent
      • 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 Container