GUIslice  0.16.0
Embedded GUI in C
XListbox.h File Reference
#include "GUIslice.h"
Include dependency graph for XListbox.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  gslc_tsXListbox
 Extended data for Listbox element. More...
 

Macros

#define GSLC_TYPEX_LISTBOX
 
#define XLISTBOX_SEL_NONE
 
#define XLISTBOX_SIZE_AUTO
 
#define XLISTBOX_BUF_OH_R
 

Typedefs

typedef bool(* GSLC_CB_XLISTBOX_SEL) (void *pvGui, void *pvElem, int16_t nSel)
 Callback function for Listbox feedback. More...
 

Functions

gslc_tsElemRefgslc_ElemXListboxCreate (gslc_tsGui *pGui, int16_t nElemId, int16_t nPage, gslc_tsXListbox *pXData, gslc_tsRect rElem, int16_t nFontId, uint8_t *pBufItems, uint16_t nBufItemsMax, int16_t nSelDefault)
 Create a Listbox Element. More...
 
void gslc_ElemXListboxSetSize (gslc_tsGui *pGui, gslc_tsElemRef *pElemRef, int8_t nRows, int8_t nCols)
 Configure the number of rows & columns to display in the listbox. More...
 
void gslc_ElemXListboxSetMargin (gslc_tsGui *pGui, gslc_tsElemRef *pElemRef, int8_t nMarginW, int8_t nMarginH)
 Configure the margin inside the listbox. More...
 
void gslc_ElemXListboxItemsSetSize (gslc_tsGui *pGui, gslc_tsElemRef *pElemRef, int16_t nItemW, int16_t nItemH)
 Configure the size of the listbox items. More...
 
void gslc_ElemXListboxItemsSetGap (gslc_tsGui *pGui, gslc_tsElemRef *pElemRef, int8_t nGap, gslc_tsColor colGap)
 Configure the gap between listbox items. More...
 
void gslc_ElemXListboxReset (gslc_tsGui *pGui, gslc_tsElemRef *pElemRef)
 Empty the listbox of all items. More...
 
bool gslc_ElemXListboxAddItem (gslc_tsGui *pGui, gslc_tsElemRef *pElemRef, const char *pStrItem)
 Add an item to the listbox. More...
 
bool gslc_ElemXListboxInsertItemAt (gslc_tsGui *pGui, gslc_tsElemRef *pElemRef, uint16_t nInsertPos, const char *pStrItem)
 Insert an item in the listbox at a specific position. More...
 
bool gslc_ElemXListboxDeleteItemAt (gslc_tsGui *pGui, gslc_tsElemRef *pElemRef, uint16_t nDeletePos)
 Insert an item in the listbox at a specific position. More...
 
bool gslc_ElemXListboxGetItem (gslc_tsGui *pGui, gslc_tsElemRef *pElemRef, int16_t nItemCurSel, char *pStrItem, uint8_t nStrItemLen)
 Get the indexed listbox item. More...
 
int16_t gslc_ElemXListboxGetItemCnt (gslc_tsGui *pGui, gslc_tsElemRef *pElemRef)
 Get the number of items in the listbox. More...
 
bool gslc_ElemXListboxDraw (void *pvGui, void *pvElemRef, gslc_teRedrawType eRedraw)
 Draw a Listbox element on the screen. More...
 
bool gslc_ElemXListboxTouch (void *pvGui, void *pvElemRef, gslc_teTouch eTouch, int16_t nRelX, int16_t nRelY)
 Handle touch events to Listbox element. More...
 
int16_t gslc_ElemXListboxGetSel (gslc_tsGui *pGui, gslc_tsElemRef *pElemRef)
 Get a Listbox element's current selection. More...
 
bool gslc_ElemXListboxSetSel (gslc_tsGui *pGui, gslc_tsElemRef *pElemRef, int16_t nItemCurSel)
 Set a Listbox element's current selection. More...
 
bool gslc_ElemXListboxSetScrollPos (gslc_tsGui *pGui, gslc_tsElemRef *pElemRef, uint16_t nScrollPos)
 Set the Listbox scroll position. More...
 
void gslc_ElemXListboxSetSelFunc (gslc_tsGui *pGui, gslc_tsElemRef *pElemRef, GSLC_CB_XLISTBOX_SEL funcCb)
 Assign the selection callback function for a Listbox. More...
 

Macro Definition Documentation

#define GSLC_TYPEX_LISTBOX
#define XLISTBOX_BUF_OH_R
#define XLISTBOX_SEL_NONE
#define XLISTBOX_SIZE_AUTO

Typedef Documentation

typedef bool(* GSLC_CB_XLISTBOX_SEL) (void *pvGui, void *pvElem, int16_t nSel)

Callback function for Listbox feedback.

Function Documentation

bool gslc_ElemXListboxAddItem ( gslc_tsGui pGui,
gslc_tsElemRef pElemRef,
const char *  pStrItem 
)

Add an item to the listbox.

Parameters
[in]pGuiPointer to GUI
[in]pElemRefPtr to Element Reference to update
[in]pStrItemString to use when creating the listbox item
Returns
true if OK, false if fail (eg. insufficient buffer storage)
gslc_tsElemRef* gslc_ElemXListboxCreate ( gslc_tsGui pGui,
int16_t  nElemId,
int16_t  nPage,
gslc_tsXListbox pXData,
gslc_tsRect  rElem,
int16_t  nFontId,
uint8_t *  pBufItems,
uint16_t  nBufItemsMax,
int16_t  nSelDefault 
)

Create a Listbox Element.

Parameters
[in]pGuiPointer to GUI
[in]nElemIdElement ID to assign (0..16383 or GSLC_ID_AUTO to autogen)
[in]nPagePage ID to attach element to
[in]pXDataPtr to extended element data structure
[in]rElemRectangle coordinates defining checkbox size
[in]nFontIdFont ID for item display
[in]pBufItemsPointer to buffer that will contain list of items
[in]nBufItemsMaxMax size of buffer for list of items (pBufItems)
[in]nSelDefaultDefault item to select
Returns
Pointer to Element reference or NULL if failure
bool gslc_ElemXListboxDeleteItemAt ( gslc_tsGui pGui,
gslc_tsElemRef pElemRef,
uint16_t  nDeletePos 
)

Insert an item in the listbox at a specific position.

Parameters
[in]pGuiPointer to GUI
[in]pElemRefPtr to Element Reference to update
[in]nDeletePosPosition to delete
Returns
true if OK, false if fail
bool gslc_ElemXListboxDraw ( void *  pvGui,
void *  pvElemRef,
gslc_teRedrawType  eRedraw 
)

Draw a Listbox element on the screen.

Parameters
[in]pvGuiVoid ptr to GUI (typecast to gslc_tsGui*)
[in]pvElemRefVoid ptr to Element reference (typecast to gslc_tsElemRef*)
[in]eRedrawRedraw mode
Returns
true if success, false otherwise
bool gslc_ElemXListboxGetItem ( gslc_tsGui pGui,
gslc_tsElemRef pElemRef,
int16_t  nItemCurSel,
char *  pStrItem,
uint8_t  nStrItemLen 
)

Get the indexed listbox item.

Parameters
[in]pGuiPointer to GUI
[in]pElemRefPtr to Element Reference to update
[in]nItemCurSelItem index to fetch
[out]pStrItemPtr to the string buffer to receive the item
[in]nStrItemLenMaximum buffer length of pStrItem
Returns
true if success, false if fail (eg. can't locate item)
int16_t gslc_ElemXListboxGetItemCnt ( gslc_tsGui pGui,
gslc_tsElemRef pElemRef 
)

Get the number of items in the listbox.

Parameters
[in]pGuiPointer to GUI
[in]pElemRefPtr to Element Reference to update
Returns
Number of items
int16_t gslc_ElemXListboxGetSel ( gslc_tsGui pGui,
gslc_tsElemRef pElemRef 
)

Get a Listbox element's current selection.

Parameters
[in]pGuiPointer to GUI
[in]pElemRefPointer to Element reference
Returns
Current Listbox selection (or -1 if none)
bool gslc_ElemXListboxInsertItemAt ( gslc_tsGui pGui,
gslc_tsElemRef pElemRef,
uint16_t  nInsertPos,
const char *  pStrItem 
)

Insert an item in the listbox at a specific position.

Parameters
[in]pGuiPointer to GUI
[in]pElemRefPtr to Element Reference to update
[in]nInsertPosInsertion position
[in]pStrItemString to use when creating the listbox item
Returns
true if OK, false if fail (eg. insufficient buffer storage)
void gslc_ElemXListboxItemsSetGap ( gslc_tsGui pGui,
gslc_tsElemRef pElemRef,
int8_t  nGap,
gslc_tsColor  colGap 
)

Configure the gap between listbox items.

Parameters
[in]pGuiPointer to GUI
[in]pElemRefPtr to Element Reference to update
[in]nGapSet the gap between listbox items (0 for none)
[in]colGapSet the color of the gap between listbox items
Returns
none
void gslc_ElemXListboxItemsSetSize ( gslc_tsGui pGui,
gslc_tsElemRef pElemRef,
int16_t  nItemW,
int16_t  nItemH 
)

Configure the size of the listbox items.

Parameters
[in]pGuiPointer to GUI
[in]pElemRefPtr to Element Reference to update
[in]nItemWSet the width of a listbox item (or -1 to auto-size)
[in]nItemHSet the height of a listbox item
Returns
none
void gslc_ElemXListboxReset ( gslc_tsGui pGui,
gslc_tsElemRef pElemRef 
)

Empty the listbox of all items.

Parameters
[in]pGuiPointer to GUI
[in]pElemRefPtr to Element Reference to update
Returns
none
void gslc_ElemXListboxSetMargin ( gslc_tsGui pGui,
gslc_tsElemRef pElemRef,
int8_t  nMarginW,
int8_t  nMarginH 
)

Configure the margin inside the listbox.

  • Defines the region bewteen the element rect and the inner listbox items
Parameters
[in]pGuiPointer to GUI
[in]pElemRefPtr to Element Reference to update
[in]nMarginWSet the margin (horizontal) inside the listbox (0 for none)
[in]nMarginHSet the margin (horizontal) inside the listbox (0 for none)
Returns
none
bool gslc_ElemXListboxSetScrollPos ( gslc_tsGui pGui,
gslc_tsElemRef pElemRef,
uint16_t  nScrollPos 
)

Set the Listbox scroll position.

Parameters
[in]pGuiPointer to GUI
[in]pElemRefPointer to Element reference
[in]nScrollPosScroll the listbox so that the nScrollPos item is at the top (0 default)
Returns
true if success, false if fail
bool gslc_ElemXListboxSetSel ( gslc_tsGui pGui,
gslc_tsElemRef pElemRef,
int16_t  nItemCurSel 
)

Set a Listbox element's current selection.

Parameters
[in]pGuiPointer to GUI
[in]pElemRefPointer to Element reference
[in]nItemCurSelListbox item to select (or -1 for none)
Returns
true if success, false if fail
void gslc_ElemXListboxSetSelFunc ( gslc_tsGui pGui,
gslc_tsElemRef pElemRef,
GSLC_CB_XLISTBOX_SEL  funcCb 
)

Assign the selection callback function for a Listbox.

Parameters
[in]pGuiPointer to GUI
[in]pElemRefPointer to Element reference
[in]funcCbFunction pointer to selection routine (or NULL for none)
Returns
none
void gslc_ElemXListboxSetSize ( gslc_tsGui pGui,
gslc_tsElemRef pElemRef,
int8_t  nRows,
int8_t  nCols 
)

Configure the number of rows & columns to display in the listbox.

Parameters
[in]pGuiPointer to GUI
[in]pElemRefPtr to Element Reference to update
[in]nRowsNumber of rows (>= 1, or XLISTBOX_SIZE_AUTO to base on content)
[in]nColsNumber of columns (>= 1)
Returns
none
bool gslc_ElemXListboxTouch ( void *  pvGui,
void *  pvElemRef,
gslc_teTouch  eTouch,
int16_t  nRelX,
int16_t  nRelY 
)

Handle touch events to Listbox element.

Parameters
[in]pvGuiVoid ptr to GUI (typecast to gslc_tsGui*)
[in]pvElemRefVoid ptr to Element reference (typecast to gslc_tsElemRef*)
[in]eTouchTouch event type
[in]nRelXTouch X coord relative to element
[in]nRelYTouch Y coord relative to element
Returns
true if success, false otherwise