CheeseBoard
A library for use with the CheeseBoard Cheddar platform
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
GfxStringListBox Class Reference

#include <GfxStringListBox.h>

Inheritance diagram for GfxStringListBox:
Inheritance graph

Public Member Functions

 GfxStringListBox (uint16_t width)
 
int16_t add (const String s)
 
bool remove (const uint8_t idx, bool compactAfter=true)
 
void draw (uint16_t xOffset=0, uint16_t yOffset=0)
 
uint16_t width ()
 
uint16_t height ()
 
int16_t find (const String s, uint8_t n=1)
 
bool select (int16_t idx)
 
int16_t selected ()
 
uint8_t scrollDown (uint8_t rows)
 
uint8_t scrollUp (uint8_t rows)
 
bool scrollTo (uint8_t idx)
 

Static Public Attributes

static const uint8_t MaxItems = 10
 

Protected Member Functions

int16_t findGap (uint8_t startAt=0)
 
int16_t findNext (uint8_t from=0)
 
int16_t findPreceding (uint8_t from=MaxItems)
 
bool isCompacted ()
 Sort the items contained in the list box using quicksort. More...
 
void compact ()
 Make used items contiguous (remove gaps) More...
 
bool isOnScreen (uint8_t idx)
 
uint8_t rowsFrom (uint8_t idx)
 

Protected Attributes

String * _items [MaxItems]
 
uint16_t _width
 
uint16_t _lineHeight
 
int16_t _selected
 
uint8_t _screenLines
 
uint8_t _screenStart
 

Detailed Description

Scrollable list box of strings [experimental].

Definition at line 9 of file GfxStringListBox.h.

Member Function Documentation

◆ add()

int16_t GfxStringListBox::add ( const String  s)

Adds a string item to the list box at the first free entry.

Parameters
sthe string to add to the list box.
Returns
index the item was added at if successful, else -1.

Definition at line 31 of file GfxStringListBox.cpp.

Here is the call graph for this function:

◆ compact()

void GfxStringListBox::compact ( )
protected

Make used items contiguous (remove gaps)

Make used items contiguous (remove gaps).

Definition at line 153 of file GfxStringListBox.cpp.

Here is the call graph for this function:

◆ draw()

void GfxStringListBox::draw ( uint16_t  xOffset = 0,
uint16_t  yOffset = 0 
)
virtual

Draw the GfxStringListBox (do not send buffer to CbOledDisplay).

Items contains NULL strings will not be displayed.

Implements GfxItem.

Definition at line 63 of file GfxStringListBox.cpp.

Here is the call graph for this function:

◆ find()

int16_t GfxStringListBox::find ( const String  s,
uint8_t  n = 1 
)
Returns
index of nth item which matches string s, or -1 if not found.
Parameters
sthe string to add.
nthe nth instance to search for.

Definition at line 123 of file GfxStringListBox.cpp.

◆ findGap()

int16_t GfxStringListBox::findGap ( uint8_t  startAt = 0)
protected
Returns
index of first "gap" (i.e. where item is NULL), or -1 if there are no gaps.
Parameters
startAtindex to start looking for gaps at.

Definition at line 88 of file GfxStringListBox.cpp.

◆ findNext()

int16_t GfxStringListBox::findNext ( uint8_t  from = 0)
protected
Returns
the first index which is not NULL after "from", or -1 if not found.
Parameters
fromthe index to search from.

Definition at line 99 of file GfxStringListBox.cpp.

◆ findPreceding()

int16_t GfxStringListBox::findPreceding ( uint8_t  from = MaxItems)
protected
Returns
the first index which is not NULL before "from", or -1 if not found.
Parameters
fromthe index to search from.

Definition at line 109 of file GfxStringListBox.cpp.

◆ height()

uint16_t GfxStringListBox::height ( )
virtual

Get object height.

Returns
Object height in pixels.

Implements GfxItem.

Definition at line 83 of file GfxStringListBox.cpp.

Here is the caller graph for this function:

◆ isCompacted()

bool GfxStringListBox::isCompacted ( )
protected

Sort the items contained in the list box using quicksort.

Sort the items contained in the list box using quicksort.

Returns
true if there are no gaps between string items, else false.

Definition at line 139 of file GfxStringListBox.cpp.

Here is the call graph for this function:

◆ isOnScreen()

bool GfxStringListBox::isOnScreen ( uint8_t  idx)
protected

Find out if idx is currently visible on screen.

Definition at line 186 of file GfxStringListBox.cpp.

◆ remove()

bool GfxStringListBox::remove ( const uint8_t  idx,
bool  compactAfter = true 
)

Remove item at index idx.

Parameters
idxthe index of the item to remove.
compactAfterif true, compact() will be called after the item is removed.
Returns
true if successful, else false

Definition at line 42 of file GfxStringListBox.cpp.

Here is the call graph for this function:

◆ rowsFrom()

uint8_t GfxStringListBox::rowsFrom ( uint8_t  idx)
protected

Find out how many rows after there from idx on (which are non-NULL).

Definition at line 200 of file GfxStringListBox.cpp.

Here is the call graph for this function:

◆ scrollDown()

uint8_t GfxStringListBox::scrollDown ( uint8_t  rows)

Scroll down the display a number of rows.

Returns
the number of rows scrolled (e.g. 0 if already as far as can do).

Definition at line 211 of file GfxStringListBox.cpp.

Here is the call graph for this function:

◆ scrollTo()

bool GfxStringListBox::scrollTo ( uint8_t  idx)

scrolls the displayed items until idx is displayed.

Note: if idx is currently displayed, no scrolling is performed.

Returns
true if scrolled OK, else false.

Definition at line 245 of file GfxStringListBox.cpp.

Here is the call graph for this function:

◆ scrollUp()

uint8_t GfxStringListBox::scrollUp ( uint8_t  rows)

Scroll up the display a number of rows.

Returns
the number of rows scrolled (e.g. 0 if already as far as can do).

Definition at line 230 of file GfxStringListBox.cpp.

Here is the call graph for this function:

◆ select()

bool GfxStringListBox::select ( int16_t  idx)

Select item at index idx.

Returns
true if successful (item exists or idx was -1).
Parameters
idxthe index of the item to select, or -1 to de-select.

Definition at line 169 of file GfxStringListBox.cpp.

◆ selected()

int16_t GfxStringListBox::selected ( )
Returns
the index of the currently selected item (or -1 if none are selected).
the index of the currently selected item (or -1 if none are selected)

Definition at line 181 of file GfxStringListBox.cpp.

◆ width()

uint16_t GfxStringListBox::width ( )
virtual

Get object width.

Returns
Object width in pixels.

Implements GfxItem.

Definition at line 78 of file GfxStringListBox.cpp.

Here is the caller graph for this function:

The documentation for this class was generated from the following files: