Package totalcross.ui

Class DynamicScrollContainer.AbstractView

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected Container c  
      int height
      Returns the height of this view.
      int parentWidth
      the width of the parent container in which this view will be visible,
      this is the width of DynamicScrollContainer
      DO NOT MODIFY This is set when adding this view to the DynamicScrollContainer.DataSource
      int viewNo
      The position of the view in the datasource
      int yEnd
      Specifies the range between which the view is visible on the scroll container Do NOT modify directly.
      int yStart
      Specifies the range between which the view is visible on the scroll container Do NOT modify directly.
    • Constructor Summary

      Constructors 
      Constructor Description
      AbstractView()  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()
      Called when this view is scrolled out of the visible view area.
      The view is destroyed
      You can overwrite to include any further garbage collection and resource release
      Container getComponent()
      Returns the container to display on the DynamicScrollContainer.
      abstract int getHeight()
      Returns the height this view will occupy in the DynamicScrollContainer.
      void initUI()
      Initializes the container that represents this view.
      You must create your UI in this method.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • yStart

        public int yStart
        Specifies the range between which the view is visible on the scroll container Do NOT modify directly. These are set when adding this view to the DynamicScrollContainer.DataSource
      • yEnd

        public int yEnd
        Specifies the range between which the view is visible on the scroll container Do NOT modify directly. These are set when adding this view to the DynamicScrollContainer.DataSource
      • height

        public int height
        Returns the height of this view. This needs to be calculated by the view itself using getHeight() and is exposed for faster referencing by DynamicScrollContainer.DataSource.
        If you know the height of your component then set this directly and have getHeight() return this value.
      • viewNo

        public int viewNo
        The position of the view in the datasource
    • Constructor Detail

      • AbstractView

        public AbstractView()
    • Method Detail

      • getHeight

        public abstract int getHeight()
        Returns the height this view will occupy in the DynamicScrollContainer. This method should not initialize the component just return the height the view will take up on the scroll container.

        If you know the height of your component then set height directly and return that value. If your component's height can only be determined when the component is painted, say for example because of text that may be wrapped, dynamically added controls,etc, then you need to calculate the height in this method, set height to the value and then return it.

      • initUI

        public void initUI()
        Initializes the container that represents this view.
        You must create your UI in this method. The UI must fit into the height specified by getHeight()
        You could lazy load data onto your ui at this point in time from a datasource, however if the loading takes a long time it will delay the painting of the ui in the DynamicScrollContainer

        CRITICAL: YOU MUST SET y on the defined rectangle of your container to be yStart otherwise the view will not be visible in DynamicScrollContainer

      • clear

        public void clear()
        Called when this view is scrolled out of the visible view area.
        The view is destroyed
        You can overwrite to include any further garbage collection and resource release