widget/menu: add member 'type_name' to CMenuItem class

This makes it easier to distinguish the object type. Normally,
type queries would be done using typeid-operation or dynamic_cast,
but we usually have RTTI disabled in the Makefiles. Presumably,
this is to avoid unnecessarily increasing the size of the binaries.
The type information defined by this member is currently only defined
in the CMenuItem class, so all subclasses are also equipped with it.
An exception is the CMenuSeparator class. If further definitions are
necessary in the subclasses, they can be retrofitted as needed.
This commit is contained in:
2023-02-13 11:03:26 +01:00
parent 8e5cfd84d3
commit e693f44786
2 changed files with 3 additions and 0 deletions

View File

@@ -68,6 +68,7 @@ CMenuItem::CMenuItem(bool Active, neutrino_msg_t DirectKey, const char * const I
active = current_active = Active;
directKey = DirectKey;
isStatic = IsStatic;
type_name = "CMenuItem";
if (IconName && *IconName)
iconName = IconName;
@@ -2512,6 +2513,7 @@ void CMenuSeparator::init(const int& Type, const neutrino_locale_t& lText, const
type = Type;
name = lText;
nameString = sText;
type_name = "CMenuSeparator";
}
int CMenuSeparator::getHeight(void)

View File

@@ -134,6 +134,7 @@ class CMenuItem : public CComponentsSignals
void handleOptionIcon(const std::string& str_option);
const char* getValName(const neutrino_locale_t& Option, const char* ValName);
public:
std::string type_name;
int height;
bool active, current_active;
bool marked;