EasyGUI  v0.1
Platform independent GUI Library
Dropdown

Dropdown widget. More...

Data Structures

struct  GUI_DROPDOWN_ITEM_t
 Dropdown string item object. More...
 
struct  GUI_DROPDOWN_t
 Dropdown object structure. More...
 

Macros

#define GUI_FLAG_DROPDOWN_OPENED   0x01
 
#define GUI_FLAG_DROPDOWN_SLIDER_ON   0x02
 
#define GUI_FLAG_DROPDOWN_SLIDER_AUTO   0x04
 
#define GUI_FLAG_DROPDOWN_OPEN_UP   0x08
 

Enumerations

enum  GUI_DROPDOWN_COLOR_t {
  GUI_DROPDOWN_COLOR_BG = 0x00, GUI_DROPDOWN_COLOR_TEXT, GUI_DROPDOWN_COLOR_SEL_FOC, GUI_DROPDOWN_COLOR_SEL_NOFOC,
  GUI_DROPDOWN_COLOR_SEL_FOC_BG, GUI_DROPDOWN_COLOR_SEL_NOFOC_BG
}
 List of dropdown colors. More...
 
enum  GUI_DROPDOWN_OPENDIR_t { GUI_DROPDOWN_OPENDIR_DOWN = 0x00, GUI_DROPDOWN_OPENDIR_UP = 0x01 }
 Dropdown open direction. More...
 

Functions

GUI_HANDLE_p gui_dropdown_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 dropdown widget. More...
 
uint8_t gui_dropdown_setcolor (GUI_HANDLE_p h, GUI_DROPDOWN_COLOR_t index, GUI_Color_t color)
 Set color to DROPDOWN. More...
 
uint8_t gui_dropdown_addstring (GUI_HANDLE_p h, const GUI_Char *text)
 Add a new string to list box. More...
 
uint8_t gui_dropdown_deletefirststring (GUI_HANDLE_p h)
 Delete first string from list. More...
 
uint8_t gui_dropdown_deletelaststring (GUI_HANDLE_p h)
 Delete last string from list. More...
 
uint8_t gui_dropdown_deletestring (GUI_HANDLE_p h, uint16_t index)
 Delete specific entry from list. More...
 
uint8_t gui_dropdown_setstring (GUI_HANDLE_p h, uint16_t index, const GUI_Char *text)
 Set string value to already added string index. More...
 
uint8_t gui_dropdown_setselection (GUI_HANDLE_p h, int16_t selection)
 Set selected value. More...
 
int16_t gui_dropdown_getselection (GUI_HANDLE_p h)
 Get selected value. More...
 
uint8_t gui_dropdown_setsliderauto (GUI_HANDLE_p h, uint8_t autoMode)
 Set auto mode for slider. More...
 
uint8_t gui_dropdown_setslidervisibility (GUI_HANDLE_p h, uint8_t visible)
 Set manual visibility for slider. More...
 
uint8_t gui_dropdown_scroll (GUI_HANDLE_p h, int16_t step)
 Scroll list if possible. More...
 
uint8_t gui_dropdown_setopendirection (GUI_HANDLE_p h, GUI_DROPDOWN_OPENDIR_t dir)
 Set opening direction for dropdown list. More...
 

Detailed Description

Dropdown widget.

Dropdown widget is another way to have single select mode of multiple choices.

image_widget_dropdown.png
Dropdown with actual opening down (left) or opening to top (right)

Example code of image above:

size_t i;
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"),
};
//Create left dropdown
handle = gui_dropdown_create(0, 10, 10, 200, 40, h, 0, 0);
for (i = 0; i < COUNT_OF(listboxtexts); i++) {
gui_dropdown_addstring(handle, listboxtexts[i]);
}
//Force slider to be visible always
//Create right widget
handle = gui_dropdown_create(0, 220, 180, 200, 40, h, 0, 0);
for (i = 0; i < COUNT_OF(listboxtexts); i++) {
gui_dropdown_addstring(handle, listboxtexts[i]);
}

Macro Definition Documentation

#define GUI_FLAG_DROPDOWN_OPEN_UP   0x08

Open dropdown in top direction instead of bottom

#define GUI_FLAG_DROPDOWN_OPENED   0x01

Dropdown is opened

#define GUI_FLAG_DROPDOWN_SLIDER_AUTO   0x04

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

#define GUI_FLAG_DROPDOWN_SLIDER_ON   0x02

Slider is currently active

Enumeration Type Documentation

List of dropdown colors.

Enumerator
GUI_DROPDOWN_COLOR_BG 

Background color index

GUI_DROPDOWN_COLOR_TEXT 

Text color index

GUI_DROPDOWN_COLOR_SEL_FOC 

Text color index of selected item when widget is in focus

GUI_DROPDOWN_COLOR_SEL_NOFOC 

Text color index of selected item when widget is not in focus

GUI_DROPDOWN_COLOR_SEL_FOC_BG 

Background color index of selected item when widget is in focus

GUI_DROPDOWN_COLOR_SEL_NOFOC_BG 

Background color index of selected item when widget is not in focus

Dropdown open direction.

Enumerator
GUI_DROPDOWN_OPENDIR_DOWN 

Dropdown will open down according to current position

GUI_DROPDOWN_OPENDIR_UP 

Dropdown will open up according to current position

Function Documentation

uint8_t gui_dropdown_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_dropdown_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 dropdown 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_dropdown_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_dropdown_deletestring, gui_dropdown_deletelaststring
uint8_t gui_dropdown_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_dropdown_deletestring, gui_dropdown_deletefirststring
uint8_t gui_dropdown_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_dropdown_deletefirststring, gui_dropdown_deletelaststring
int16_t gui_dropdown_getselection ( GUI_HANDLE_p  h)

Get selected value.

Parameters
[in,out]hWidget handle
Return values
Selectionnumber or -1 if no selection
See also
gui_dropdown_setselection
uint8_t gui_dropdown_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_dropdown_setcolor ( GUI_HANDLE_p  h,
GUI_DROPDOWN_COLOR_t  index,
GUI_Color_t  color 
)

Set color to DROPDOWN.

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

Set opening direction for dropdown list.

Parameters
[in,out]hWidget handle
[in]dirOpening direction. This parameter can be a value of GUI_DROPDOWN_OPENDIR_t enumeration
Return values
1Open direction has been changed
0Open direction has not been changed
uint8_t gui_dropdown_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_dropdown_getselection
uint8_t gui_dropdown_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_dropdown_setslidervisibility
uint8_t gui_dropdown_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_dropdown_setsliderauto
uint8_t gui_dropdown_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