# dlangui.widgets.lists

DLANGUI library.
This module contains list widgets implementation.
Similar to lists implementation in Android UI API.
Synopsis:

    import dlangui.widgets.lists;

License:
Boost License 1.0
Authors:
Vadim Lopatin, coolreader.org@gmail.com

interface ListAdapter;
  list widget adapter provides items for list widgets
  abstract @property int itemCount();
    returns number of widgets in list
  abstract Widget itemWidget(int index);
    return list item widget by item index
  abstract uint itemState(int index);
    return list item's state flags
  abstract uint setItemState(int index, uint flags);
    set one or more list item's state flags, returns updated state
  abstract uint resetItemState(int index, uint flags);
    reset one or more list item's state flags, returns updated state
class WidgetListAdapter: dlangui.widgets.lists.ListAdapter;
  List adapter for simple list of widget instances
  @property ref WidgetList widgets();
    list of widgets to display
  @property int itemCount();
    returns number of widgets in list
  Widget itemWidget(int index);
    return list item widget by item index
  uint itemState(int index);
    return list item's state flags
  uint setItemState(int index, uint flags);
    set one or more list item's state flags, returns updated state
  uint resetItemState(int index, uint flags);
    reset one or more list item's state flags, returns updated state
class ListWidget: dlangui.widgets.widget.WidgetGroup, dlangui.widgets.controls.OnScrollHandler;
  List
  @property Orientation orientation();
    returns linear layout orientation (Vertical, Horizontal)
  @property ListWidget orientation(Orientation value);
    sets linear layout orientation
  protected int _firstVisibleItem;
    first visible item index
  protected int _scrollPosition;
    scroll position - offset of scroll area
  protected int _maxScrollPosition;
    maximum scroll position
  protected Rect _clientRc;
    client area rectangle (counting padding, margins, and scrollbar)
  protected int _totalSize;
    total height of all items for Vertical orientation, or width for Horizontal
  protected int _hoverItemIndex;
    item with Hover state, -1 if no such item
  protected int _selectedItemIndex;
    item with Selected state, -1 if no such item
  protected bool _selectOnHover;
    when true, mouse hover selects underlying item
  @property bool selectOnHover();
    when true, mouse hover selects underlying item
  @property ListWidget selectOnHover(bool select);
    when true, mouse hover selects underlying item
  protected bool _clickOnButtonDown;
    if true, generate itemClicked on mouse down instead mouse up event
  Rect itemRectNoScroll(int index);
    returns rectangle for item (not scrolled, first item starts at 0,0)
  Rect itemRect(int index);
    returns rectangle for item (scrolled)
  int itemByPosition(int pos);
    returns item index by 0-based offset from top/left of list content
  protected bool _ownAdapter;
    when true, need to destroy adapter on list destroy
  @property ListAdapter adapter();
    get adapter
  @property ListWidget adapter(ListAdapter adapter);
    set adapter
  @property ListWidget ownAdapter(ListAdapter adapter);
    set adapter, which will be owned by list (destroy will be called for adapter on widget destroy)
  @property int itemCount();
    returns number of widgets in list
  Widget itemWidget(int index);
    return list item widget by item index
  bool itemEnabled(int index);
    returns true if item with corresponding index is enabled
  protected void selectionChanged(int index, int previouslySelectedItem = -1);
    override to handle change of selection
  protected void itemClicked(int index);
    override to handle mouse up on item
  protected void handleFocusChange(bool focused);
    override to handle focus changes
  void makeSelectionVisible();
    ensure selected item is visible (scroll if necessary)
  void makeItemVisible(int itemIndex);
    ensure item is visible
  bool moveSelection(int direction, bool wrapAround = true);
    move selection
  bool onScrollEvent(AbstractSlider source, ScrollEvent event);
    handle scroll event
  void measure(int parentWidth, int parentHeight);
    Measure widget according to desired width and height constraints. (Step 1 of two phase layout).
  void layout(Rect rc);
    Set widget rectangle to specified value and layout widget contents. (Step 2 of two phase layout).
  void onDraw(DrawBuf buf);
    Draw widget at its position to buffer
  bool onKeyEvent(KeyEvent event);
    list navigation using keys
  bool onMouseEvent(MouseEvent event);
    process mouse event; return true if event is processed by widget.

Page generated by Ddoc. Vadim Lopatin, 2014