LVGLPlusPlus
C++ library on top of the lovely LVGL project.
Loading...
Searching...
No Matches
lvppOptions Class Referenceabstract

Utility class to aid in consistent handling of all lv_ widgets which have a list of choices. This means roller, dropdown, and from this library, lvppCycleButton. Each child class will use this class to keep track of the options and make them modifyable in a consistent manner. The ultimate setting of the values in the child class is done by that child implementing their version of lvOptionSetter(). More...

#include <lvppBase.h>

Inheritance diagram for lvppOptions:

Public Member Functions

virtual void setOptions (const char *pOpts)
 Set the Options all in one shot from a const char*.
 
virtual void setOptions (std::vector< std::string > &_opts)
 Set the Options using a vector of strings.
 
virtual void setOptionsWithIDs (std::vector< std::pair< std::string, uint64_t > > &valIDs)
 Set the Options along with a related ID. This is intended to give the user a more meaningful item to 'get' than text or index of what has been selected. Used in conjunction with getCurrentID()
 
virtual void addOption (const char *pOpt)
 Add a single option to the options list.
 
virtual void addOptionWithID (const char *pOpt, uint64_t id)
 Add a single option to the options list and pair it with a meaningful ID. To be used in conjunction with getSelectedID().
 
virtual void addOption (std::string &_opt)
 Add a single option to the options list.
 
virtual void addOptionWithID (std::string &_opt, uint64_t id)
 Add a single option to the options list and pair it with a meaningful ID. To be used in conjunction with getSelectedID().
 
virtual void clearOptions ()
 Removes all entries from the options list. NOTE: Method does not clear the LVGL widget. User should declare their own clearOptions() method and make a call to the base object for clearing the options list prior to the user clearing the widget's actual list visually.
 
virtual uint64_t getSelectedID ()
 Get the ID associated with the currently selected item. Using this method only makes sense if the list of options was built using setOptionsWithIDs() and/or addOptionWithID().
 

Protected Member Functions

virtual void lvOptionSetter (const char *pOpts)=0
 This is the pure virtual which must be implemented by any class that utilizes lvppOptions. It is called by the 'set' functions to do the actual setting. Since lvppOptions is just a utility class, it must rely on the the child to do the actual appropriate set function.
 
virtual uint16_t lvOptionGetIndex ()=0
 This is the pure virtual method which must be implemented by any class that utilizes lvppOptions. The implementation should return the index of the currently selected value in the list. The specific function will vary based on what the child's widget type is.
 
const char * getNewlineSepOptions ()
 Packs all the option strings into a single newline separated pointer.
 

Protected Attributes

std::string oneString
 Temp area for getNewlineSepOptions()
 
std::vector< std::string > options
 The vector of options kept locally.
 
std::vector< uint64_t > idList
 The vector of associated ID values (if used)
 

Detailed Description

Utility class to aid in consistent handling of all lv_ widgets which have a list of choices. This means roller, dropdown, and from this library, lvppCycleButton. Each child class will use this class to keep track of the options and make them modifyable in a consistent manner. The ultimate setting of the values in the child class is done by that child implementing their version of lvOptionSetter().

Member Function Documentation

◆ addOption() [1/2]

void lvppOptions::addOption ( const char *  pOpt)
virtual

Add a single option to the options list.

Parameters
pOptconst char* to a single option to add to the list.

◆ addOption() [2/2]

void lvppOptions::addOption ( std::string &  _opt)
virtual

Add a single option to the options list.

Parameters
_optreference to a std::string of a single option to add to the list.

◆ addOptionWithID() [1/2]

void lvppOptions::addOptionWithID ( const char *  pOpt,
uint64_t  id 
)
virtual

Add a single option to the options list and pair it with a meaningful ID. To be used in conjunction with getSelectedID().

Parameters
pOptconst char* to a single option to add to the list.
idID to associate with this option.

◆ addOptionWithID() [2/2]

void lvppOptions::addOptionWithID ( std::string &  _opt,
uint64_t  id 
)
virtual

Add a single option to the options list and pair it with a meaningful ID. To be used in conjunction with getSelectedID().

Parameters
_optconst char* to a single option to add to the list.
idID to associate with this option.

◆ clearOptions()

void lvppOptions::clearOptions ( void  )
virtual

Removes all entries from the options list. NOTE: Method does not clear the LVGL widget. User should declare their own clearOptions() method and make a call to the base object for clearing the options list prior to the user clearing the widget's actual list visually.

Reimplemented in lvppCycleButton, lvppDropdown, and lvppRoller.

◆ getNewlineSepOptions()

const char * lvppOptions::getNewlineSepOptions ( )
protected

Packs all the option strings into a single newline separated pointer.

◆ getSelectedID()

uint64_t lvppOptions::getSelectedID ( )
virtual

Get the ID associated with the currently selected item. Using this method only makes sense if the list of options was built using setOptionsWithIDs() and/or addOptionWithID().

Returns
uint64_t the pre-set ID associated with this current selected value/index.

◆ lvOptionGetIndex()

virtual uint16_t lvppOptions::lvOptionGetIndex ( )
protectedpure virtual

This is the pure virtual method which must be implemented by any class that utilizes lvppOptions. The implementation should return the index of the currently selected value in the list. The specific function will vary based on what the child's widget type is.

Returns
uint16_t The index of the currently selected / displayed value. This is zero-based.

Implemented in lvppCycleButton, lvppDropdown, and lvppRoller.

◆ lvOptionSetter()

virtual void lvppOptions::lvOptionSetter ( const char *  pOpts)
protectedpure virtual

This is the pure virtual which must be implemented by any class that utilizes lvppOptions. It is called by the 'set' functions to do the actual setting. Since lvppOptions is just a utility class, it must rely on the the child to do the actual appropriate set function.

Parameters
pOptsnewline-separated list of options.

Implemented in lvppCycleButton, lvppDropdown, and lvppRoller.

◆ setOptions() [1/2]

void lvppOptions::setOptions ( const char *  pOpts)
virtual

Set the Options all in one shot from a const char*.

Parameters
pOptsOptions all in one string separated by
newline characters.

Reimplemented in lvppCycleButton, lvppDropdown, and lvppRoller.

◆ setOptions() [2/2]

void lvppOptions::setOptions ( std::vector< std::string > &  _opts)
virtual

Set the Options using a vector of strings.

Parameters
_optsreference to a std::vector<std::string> which contains all of the options.

Reimplemented in lvppCycleButton, lvppDropdown, and lvppRoller.

◆ setOptionsWithIDs()

void lvppOptions::setOptionsWithIDs ( std::vector< std::pair< std::string, uint64_t > > &  valIDs)
virtual

Set the Options along with a related ID. This is intended to give the user a more meaningful item to 'get' than text or index of what has been selected. Used in conjunction with getCurrentID()

Parameters
valIDs

Member Data Documentation

◆ idList

std::vector<uint64_t> lvppOptions::idList
protected

The vector of associated ID values (if used)

◆ oneString

std::string lvppOptions::oneString
protected

Temp area for getNewlineSepOptions()

◆ options

std::vector<std::string> lvppOptions::options
protected

The vector of options kept locally.


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