File ScrollView.lua

Functions

ScrollView:computeScrollPos (up, num) Compute new scroll position, given specified adjustment.
ScrollView:confineScrollPos (pos) Compute new scroll position, if necessary, to assure position is in range.
ScrollView:dataIndices () Iterator: delivers visible row indexes 1 - N, where N is between nil and number of rows on a page.
ScrollView:fillIndices () Returns iterator that returns prop index only, to fill balance of a page with nil for when data is short of a page.
ScrollView:getBinding (t) Get a pref binding as specified in parameter table.
ScrollView:getPrefIndex (propIndex) Get pref index for specified prop index.
ScrollView:getScrollPos () Get actual scroll position.
ScrollView:new (t) Constructor for new instance.
ScrollView:newClass (t) Constructor for extending class.
ScrollView:scroll (up, num) Scroll or page the view.
ScrollView:setDataSize (nRows) Set total number of rows to be scrolled or paged.
ScrollView:setPageSize (nRows) Set number of rows in a page.
ScrollView:setScrollPos (pos) Set scroll position to specified value.


Functions

ScrollView:computeScrollPos (up, num)
Compute new scroll position, given specified adjustment.

Parameters:

  • up: (boolean, default nil) true => scroll upward, false => scroll one downward, nil => just update scroll position by confining.
  • num: (number, default one page) 1 => scroll one row. nil means scroll one page. Huge => all the way. Ignored if up is nil.

Usage:

    call in response to scroll buttons. 
ScrollView:confineScrollPos (pos)
Compute new scroll position, if necessary, to assure position is in range.

Parameters:

  • pos:
ScrollView:dataIndices ()
Iterator: delivers visible row indexes 1 - N, where N is between nil and number of rows on a page. Its short when there isn't enough data to fill the page (based on item count). visible index is paired with data item index.

Usage:

    call data-indexes followed by fill-indexes. 
ScrollView:fillIndices ()
Returns iterator that returns prop index only, to fill balance of a page with nil for when data is short of a page.
ScrollView:getBinding (t)
Get a pref binding as specified in parameter table.

Parameters:

  • t: parameter table
    • keys (table of strings, required) array of all keys for this data item.
    • index (number, required) row index this binding applies to.
ScrollView:getPrefIndex (propIndex)
Get pref index for specified prop index.

Parameters:

  • propIndex:

Usage:

    This allows calling context to lookup the proper preference to set based on preference index when a scrollable property changes. 
ScrollView:getScrollPos ()
Get actual scroll position.
ScrollView:new (t)
Constructor for new instance.

Parameters:

  • t: Parameter table:
    • global (boolean, required) governs whether global or local pref bindings are used.
    • pageSize (number, default: nil) set in constructor, or further on down the road, but do set.
    • dataSize (number, default: nil) set in constructor, or further on down the road, but do set.

Usage:

    wraps a row view for scrolling or paging. 
ScrollView:newClass (t)
Constructor for extending class.

Parameters:

  • t:
ScrollView:scroll (up, num)
Scroll or page the view.

Parameters:

  • up: (boolean, required) true => scroll one upward (pass true in response to up(1) button).
  • num: (number, default one page) 1 => scroll one row. nil means scroll one page. Huge => all the way.

Usage:

    call in response to scroll buttons. 
ScrollView:setDataSize (nRows)
Set total number of rows to be scrolled or paged.

Parameters:

  • nRows: (number, required) Number of items total.

Usage:

  • If set in constructor, this method is not necessary, otherwise it is.
  • Designed with rows in mind, but could just as easily be columns, or even sprinkled about. 
ScrollView:setPageSize (nRows)
Set number of rows in a page.

Parameters:

  • nRows: (number, required) Number of items in a page.

Usage:

  • If set in constructor, this method is not necessary, otherwise it is.
  • Designed with rows in mind, but could just as easily be columns, or even sprinkled about. 
ScrollView:setScrollPos (pos)
Set scroll position to specified value.

Parameters:

  • pos: (number, required) row number for page top - will be confined if necessary to valid range.

Return value:

    actualPos (number) actual scroll position, after possible adjustment.

Valid XHTML 1.0!