EasyGUI  v0.1
Platform independent GUI Library
Listbox

LISTBOX widget. More...

Data Structures

struct  GUI_LISTBOX_ITEM_t
 LISTBOX string item object. More...
 
struct  GUI_LISTBOX_t
 LISTBOX object structure. More...
 

Macros

#define GUI_FLAG_LISTBOX_SLIDER_ON   0x01
 
#define GUI_FLAG_LISTBOX_SLIDER_AUTO   0x02
 

Enumerations

enum  GUI_LISTBOX_COLOR_t {
  GUI_LISTBOX_COLOR_BG = 0x00, GUI_LISTBOX_COLOR_TEXT, GUI_LISTBOX_COLOR_SEL_FOC, GUI_LISTBOX_COLOR_SEL_NOFOC,
  GUI_LISTBOX_COLOR_SEL_FOC_BG, GUI_LISTBOX_COLOR_SEL_NOFOC_BG
}
 List of listbox colors. More...
 

Functions

GUI_HANDLE_p gui_listbox_create (GUI_ID_t id, GUI_iDim_t x, GUI_iDim_t y, GUI_Dim_t width, GUI_Dim_t height, GUI_HANDLE_p parent, GUI_WIDGET_CALLBACK_t cb, uint16_t flags)
 Create new listbox widget. More...
 
uint8_t gui_listbox_setcolor (GUI_HANDLE_p h, GUI_LISTBOX_COLOR_t index, GUI_Color_t color)
 Set color to listbox. More...
 
uint8_t gui_listbox_addstring (GUI_HANDLE_p h, const GUI_Char *text)
 Add a new string to list box. More...
 
uint8_t gui_listbox_deletefirststring (GUI_HANDLE_p h)
 Delete first string from list. More...
 
uint8_t gui_listbox_deletelaststring (GUI_HANDLE_p h)
 Delete last string from list. More...
 
uint8_t gui_listbox_deletestring (GUI_HANDLE_p h, uint16_t index)
 Delete specific entry from list. More...
 
uint8_t gui_listbox_setstring (GUI_HANDLE_p h, uint16_t index, const GUI_Char *text)
 Set string value to already added string index. More...
 
uint8_t gui_listbox_setselection (GUI_HANDLE_p h, int16_t selection)
 Set selected value. More...
 
int16_t gui_listbox_getselection (GUI_HANDLE_p h)
 Get selected value. More...
 
uint8_t gui_listbox_setsliderauto (GUI_HANDLE_p h, uint8_t autoMode)
 Set auto mode for slider. More...
 
uint8_t gui_listbox_setslidervisibility (GUI_HANDLE_p h, uint8_t visible)
 Set manual visibility for slider. More...
 
uint8_t gui_listbox_scroll (GUI_HANDLE_p h, int16_t step)
 Scroll list if possible. More...
 

Detailed Description

LISTBOX widget.

Listbox widget is simple widget to display single list of data. For detailed support of list displays, refer to List view widget

image_widget_listbox.png
Listbox in passive (left) and active (focused, right image) modes

Example code of image above

GUI_Char* listboxtexts[] = {
_GT("Item 0"),
_GT("Item 1"),
_GT("Item 2"),
_GT("Item 3"),
_GT("Item 4"),
_GT("Item 5"),
_GT("Item 6"),
_GT("Item 7"),
_GT("Item 8"),
_GT("Item 9"),
_GT("Item 10"),
_GT("Item 11"),
_GT("Item 12"),
};
size_t i;
//Create left listbox
handle = gui_listbox_create(1, 10, 10, 190, 195, h, 0, 0);
for (i = 0; i < COUNT_OF(listboxtexts); i++) {
gui_listbox_addstring(handle, listboxtexts[i]);
}
//Force visible slider
//Create right list box
handle = gui_listbox_create(1, 210, 10, 200, 195, h, 0, 0);
for (i = 0; i < COUNT_OF(listboxtexts); i++) {
gui_listbox_addstring(handle, listboxtexts[i]);
}

Macro Definition Documentation

#define GUI_FLAG_LISTBOX_SLIDER_AUTO   0x02

Show right slider automatically when required, otherwise, manual mode is used

#define GUI_FLAG_LISTBOX_SLIDER_ON   0x01

Slider is currently active

Enumeration Type Documentation

List of listbox colors.

Enumerator
GUI_LISTBOX_COLOR_BG 

Background color

GUI_LISTBOX_COLOR_TEXT 

Text color index

GUI_LISTBOX_COLOR_SEL_FOC 

Text color of selected item when widget is in focus

GUI_LISTBOX_COLOR_SEL_NOFOC 

Text color of selected item when widget is not in focus

GUI_LISTBOX_COLOR_SEL_FOC_BG 

Background color of selected item when widget is in focus

GUI_LISTBOX_COLOR_SEL_NOFOC_BG 

Background color of selected item when widget is not in focus

Function Documentation

uint8_t gui_listbox_addstring ( GUI_HANDLE_p  h,
const GUI_Char text 
)

Add a new string to list box.

Parameters
[in,out]hWidget handle
[in]*textPointer to text to add to list. Only pointer is saved to memory!
Return values
1String added to the end
0String not added
GUI_HANDLE_p gui_listbox_create ( GUI_ID_t  id,
GUI_iDim_t  x,
GUI_iDim_t  y,
GUI_Dim_t  width,
GUI_Dim_t  height,
GUI_HANDLE_p  parent,
GUI_WIDGET_CALLBACK_t  cb,
uint16_t  flags 
)

Create new listbox widget.

Parameters
[in]idWidget unique ID to use for identity for callback processing
[in]xWidget X position relative to parent widget
[in]yWidget Y position relative to parent widget
[in]widthWidget width in units of pixels
[in]heightWidget height in uints of pixels
[in]parentParent widget handle. Set to NULL to use current active parent widget
[in]cbPointer to GUI_WIDGET_CALLBACK_t callback function. Set to NULL to use default widget callback
[in]flagsFlags for widget creation
Return values
>0: GUI_HANDLE_p object of created widget
0Widget creation failed
uint8_t gui_listbox_deletefirststring ( GUI_HANDLE_p  h)

Delete first string from list.

Parameters
[in,out]hWidget handle
Return values
1String deleted
0String not deleted
See also
gui_listbox_deletestring, gui_listbox_deletelaststring
uint8_t gui_listbox_deletelaststring ( GUI_HANDLE_p  h)

Delete last string from list.

Parameters
[in,out]hWidget handle
Return values
1String deleted
0String not deleted
See also
gui_listbox_deletestring, gui_listbox_deletefirststring
uint8_t gui_listbox_deletestring ( GUI_HANDLE_p  h,
uint16_t  index 
)

Delete specific entry from list.

Parameters
[in,out]hWidget handle
[in]indexList index (position) to delete
Return values
1String deleted
0String not deleted
See also
gui_listbox_deletefirststring, gui_listbox_deletelaststring
int16_t gui_listbox_getselection ( GUI_HANDLE_p  h)

Get selected value.

Parameters
[in,out]hWidget handle
Return values
Selectionnumber or -1 if no selection
See also
gui_listbox_setselection
uint8_t gui_listbox_scroll ( GUI_HANDLE_p  h,
int16_t  step 
)

Scroll list if possible.

Parameters
[in,out]hWidget handle
[in]stepStep to scroll. Positive step will scroll up, negative will scroll down
Return values
1Scroll successful
0Scroll not successful
uint8_t gui_listbox_setcolor ( GUI_HANDLE_p  h,
GUI_LISTBOX_COLOR_t  index,
GUI_Color_t  color 
)

Set color to listbox.

Parameters
[in,out]hWidget handle
[in]indexIndex in array of colors. This parameter can be a value of GUI_LISTBOX_COLOR_t enumeration
[in]colorActual color code to set
Return values
1Color was set ok
0Color was not set
uint8_t gui_listbox_setselection ( GUI_HANDLE_p  h,
int16_t  selection 
)

Set selected value.

Parameters
[in,out]hWidget handle
[in]selectionSet to -1 to invalidate selection or 0 - count-1 for specific selection
Return values
1Selection changed
0Selection not changed
See also
gui_listbox_getselection
uint8_t gui_listbox_setsliderauto ( GUI_HANDLE_p  h,
uint8_t  autoMode 
)

Set auto mode for slider.

Note
When it is enabled, slider will only appear if needed to show more entries on list
Parameters
[in,out]hWidget handle
[in]autoModeAuto mode status. Set to 1 for auto mode or 0 for manual mode
Return values
1Set OK
0Set ERROR
See also
gui_listbox_setslidervisibility
uint8_t gui_listbox_setslidervisibility ( GUI_HANDLE_p  h,
uint8_t  visible 
)

Set manual visibility for slider.

Note
Slider must be in manual mode in order to get this to work
Parameters
[in,out]hWidget handle
[in]visibleSlider visible status, 1 or 0
Return values
1Set to desired value
0Not set to desired value
See also
gui_listbox_setsliderauto
uint8_t gui_listbox_setstring ( GUI_HANDLE_p  h,
uint16_t  index,
const GUI_Char text 
)

Set string value to already added string index.

Parameters
[in,out]hWidget handle
[in]indexIndex (position) on list to set/change text
[in]*textPointer to text to add to list. Only pointer is saved to memory!
Return values
1String changed
0String not changed