mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-27 07:23:09 +02:00
Preparing the menu classes for Lua Part #1
- Remove CNonLocalizedMenuSeparator - Add overloaded function CMenuSeparator for non local THX Martii
This commit is contained in:
@@ -491,7 +491,7 @@ int CPersonalizeGui::ShowMenuOptions(const int& widget)
|
||||
CMenuSeparator * pm_subhead = new CMenuSeparator(CMenuSeparator::ALIGN_LEFT | CMenuSeparator::SUB_HEAD | CMenuSeparator::STRING);
|
||||
string s_sh = g_Locale->getText(LOCALE_PERSONALIZE_ACCESS);
|
||||
s_sh += ": " + mn_name;
|
||||
pm_subhead->setString(s_sh);
|
||||
pm_subhead->setName(s_sh);
|
||||
|
||||
pm->addItem(pm_subhead);
|
||||
pm->addIntroItems();
|
||||
|
@@ -194,7 +194,7 @@ bool CFlashUpdate::selectHttpImage(void)
|
||||
}
|
||||
//updates_lists.push_back(url.substr(startpos, endpos - startpos));
|
||||
|
||||
SelectionWidget.addItem(new CNonLocalizedMenuSeparator(updates_lists.rbegin()->c_str(), LOCALE_FLASHUPDATE_SELECTIMAGE));
|
||||
SelectionWidget.addItem(new CMenuSeparator(CMenuSeparator::STRING | CMenuSeparator::LINE, updates_lists.rbegin()->c_str()));
|
||||
if (httpTool.downloadFile(url, gTmpPath LIST_OF_UPDATES_LOCAL_FILENAME, 20))
|
||||
{
|
||||
std::ifstream in(gTmpPath LIST_OF_UPDATES_LOCAL_FILENAME);
|
||||
|
@@ -56,25 +56,29 @@ CMenuForwarder * const GenericMenuNext = &CGenericMenuNext;
|
||||
|
||||
CMenuItem::CMenuItem()
|
||||
{
|
||||
x = -1;
|
||||
directKey = CRCInput::RC_nokey;
|
||||
iconName = "";
|
||||
x = -1;
|
||||
directKey = CRCInput::RC_nokey;
|
||||
iconName = "";
|
||||
iconName_Info_right = "";
|
||||
used = false;
|
||||
icon_frame_w = 10;
|
||||
hint = NONEXISTANT_LOCALE;
|
||||
isStatic = false;
|
||||
used = false;
|
||||
icon_frame_w = 10;
|
||||
hint = NONEXISTANT_LOCALE;
|
||||
name = NONEXISTANT_LOCALE;
|
||||
nameString = "";
|
||||
isStatic = false;
|
||||
marked = false;
|
||||
inert = false;
|
||||
}
|
||||
|
||||
void CMenuItem::init(const int X, const int Y, const int DX, const int OFFX)
|
||||
{
|
||||
x = X;
|
||||
y = Y;
|
||||
dx = DX;
|
||||
offx = OFFX;
|
||||
name_start_x = x + offx + icon_frame_w;
|
||||
item_color = COL_MENUCONTENT_TEXT;
|
||||
item_bgcolor = COL_MENUCONTENT_PLUS_0;
|
||||
x = X;
|
||||
y = Y;
|
||||
dx = DX;
|
||||
offx = OFFX;
|
||||
name_start_x = x + offx + icon_frame_w;
|
||||
item_color = COL_MENUCONTENT_TEXT;
|
||||
item_bgcolor = COL_MENUCONTENT_PLUS_0;
|
||||
}
|
||||
|
||||
void CMenuItem::setActive(const bool Active)
|
||||
@@ -87,6 +91,20 @@ void CMenuItem::setActive(const bool Active)
|
||||
paint();
|
||||
}
|
||||
|
||||
void CMenuItem::setMarked(const bool Marked)
|
||||
{
|
||||
marked = Marked;
|
||||
if (used && x != -1)
|
||||
paint();
|
||||
}
|
||||
|
||||
void CMenuItem::setInert(const bool Inert)
|
||||
{
|
||||
inert = Inert;
|
||||
if (used && x != -1)
|
||||
paint();
|
||||
}
|
||||
|
||||
void CMenuItem::setItemButton(const std::string& icon_Name, const bool is_select_button)
|
||||
{
|
||||
if (is_select_button)
|
||||
@@ -102,11 +120,16 @@ void CMenuItem::initItemColors(const bool select_mode)
|
||||
item_color = COL_MENUCONTENTSELECTED_TEXT;
|
||||
item_bgcolor = COL_MENUCONTENTSELECTED_PLUS_0;
|
||||
}
|
||||
else if (!active)
|
||||
else if (!active || inert)
|
||||
{
|
||||
item_color = COL_MENUCONTENTINACTIVE_TEXT;
|
||||
item_bgcolor = COL_MENUCONTENTINACTIVE_PLUS_0;
|
||||
}
|
||||
else if (marked)
|
||||
{
|
||||
item_color = COL_MENUCONTENT_TEXT;
|
||||
item_bgcolor = COL_MENUCONTENT_PLUS_1;
|
||||
}
|
||||
else
|
||||
{
|
||||
item_color = COL_MENUCONTENT_TEXT;
|
||||
@@ -281,6 +304,13 @@ void CMenuItem::paintItemButton(const bool select_mode, const int &item_height,
|
||||
}
|
||||
}
|
||||
|
||||
const char *CMenuItem::getName(void)
|
||||
{
|
||||
if (name != NONEXISTANT_LOCALE)
|
||||
return g_Locale->getText(name);
|
||||
return nameString.c_str();
|
||||
}
|
||||
|
||||
//small helper class to manage values e.g.: handling needed but deallocated widget objects
|
||||
CMenuGlobal::CMenuGlobal()
|
||||
{
|
||||
@@ -1151,10 +1181,10 @@ void CMenuWidget::addKey(neutrino_msg_t key, CMenuTarget *menue, const std::stri
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------
|
||||
CMenuOptionNumberChooser::CMenuOptionNumberChooser(const neutrino_locale_t name, int * const OptionValue, const bool Active, const int min_value, const int max_value, CChangeObserver * const Observ, const int print_offset, const int special_value, const neutrino_locale_t special_value_name, const char * non_localized_name, bool sliderOn)
|
||||
CMenuOptionNumberChooser::CMenuOptionNumberChooser(const neutrino_locale_t name1, int * const OptionValue, const bool Active, const int min_value, const int max_value, CChangeObserver * const Observ, const int print_offset, const int special_value, const neutrino_locale_t special_value_name, const char * non_localized_name, bool sliderOn)
|
||||
{
|
||||
height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
|
||||
optionName = name;
|
||||
optionName = name1;
|
||||
active = Active;
|
||||
optionValue = OptionValue;
|
||||
|
||||
@@ -1930,33 +1960,41 @@ CMenuDForwarderNonLocalized::~CMenuDForwarderNonLocalized()
|
||||
//-------------------------------------------------------------------------------------------------------------------------------
|
||||
CMenuSeparator::CMenuSeparator(const int Type, const neutrino_locale_t Text, bool IsStatic)
|
||||
{
|
||||
directKey = CRCInput::RC_nokey;
|
||||
iconName = "";
|
||||
type = Type;
|
||||
text = Text;
|
||||
isStatic = IsStatic;
|
||||
directKey = CRCInput::RC_nokey;
|
||||
iconName = "";
|
||||
type = Type;
|
||||
name = Text;
|
||||
nameString = "";
|
||||
isStatic = IsStatic;
|
||||
}
|
||||
|
||||
CMenuSeparator::CMenuSeparator(const int Type, const std::string Text, bool IsStatic)
|
||||
{
|
||||
directKey = CRCInput::RC_nokey;
|
||||
iconName = "";
|
||||
type = Type;
|
||||
name = NONEXISTANT_LOCALE;
|
||||
nameString = Text;
|
||||
isStatic = IsStatic;
|
||||
}
|
||||
|
||||
int CMenuSeparator::getHeight(void) const
|
||||
{
|
||||
if (separator_text.empty() && text == NONEXISTANT_LOCALE)
|
||||
if (nameString.empty() && name == NONEXISTANT_LOCALE)
|
||||
return 10;
|
||||
else
|
||||
return g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
|
||||
return g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
|
||||
}
|
||||
|
||||
const char * CMenuSeparator::getString(void)
|
||||
void CMenuSeparator::setName(const std::string& t)
|
||||
{
|
||||
if (!separator_text.empty())
|
||||
return separator_text.c_str();
|
||||
else
|
||||
return g_Locale->getText(text);
|
||||
name = NONEXISTANT_LOCALE;
|
||||
nameString = t;
|
||||
}
|
||||
|
||||
void CMenuSeparator::setString(const std::string& s_text)
|
||||
void CMenuSeparator::setName(const neutrino_locale_t t)
|
||||
{
|
||||
separator_text = s_text;
|
||||
name = t;
|
||||
nameString = "";
|
||||
}
|
||||
|
||||
int CMenuSeparator::getWidth(void)
|
||||
@@ -1964,11 +2002,9 @@ int CMenuSeparator::getWidth(void)
|
||||
int w = 0;
|
||||
if (type & LINE)
|
||||
w = 30; /* 15 pixel left and right */
|
||||
if ((type & STRING) && text != NONEXISTANT_LOCALE)
|
||||
{
|
||||
const char *l_text = getString();
|
||||
w += g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(l_text, true);
|
||||
}
|
||||
const char *l_name = getName();
|
||||
if ((type & STRING) && *l_name)
|
||||
w += g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(l_name, true);
|
||||
return w;
|
||||
}
|
||||
|
||||
@@ -1996,11 +2032,11 @@ int CMenuSeparator::paint(bool selected)
|
||||
}
|
||||
if ((type & STRING))
|
||||
{
|
||||
const char * l_text = getString();
|
||||
const char * l_name = getName();
|
||||
|
||||
if (text != NONEXISTANT_LOCALE || strlen(l_text) != 0)
|
||||
if (*l_name)
|
||||
{
|
||||
int stringwidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(l_text, true); // UTF-8
|
||||
int stringwidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(l_name, true); // UTF-8
|
||||
|
||||
/* if no alignment is specified, align centered */
|
||||
if (type & ALIGN_LEFT)
|
||||
@@ -2012,7 +2048,7 @@ int CMenuSeparator::paint(bool selected)
|
||||
|
||||
frameBuffer->paintBoxRel(name_start_x-5, y, stringwidth+10, height, item_bgcolor);
|
||||
|
||||
paintItemCaption(selected, height, l_text);
|
||||
paintItemCaption(selected, height, l_name);
|
||||
}
|
||||
}
|
||||
return y+ height;
|
||||
|
@@ -45,6 +45,12 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
extern "C" {
|
||||
#include <lua.h>
|
||||
#include <lauxlib.h>
|
||||
#include <lualib.h>
|
||||
}
|
||||
|
||||
#define NO_WIDGET_ID -1
|
||||
|
||||
typedef int mn_widget_id_t;
|
||||
@@ -90,16 +96,24 @@ class CMenuItem
|
||||
fb_pixel_t item_color, item_bgcolor;
|
||||
|
||||
void initItemColors(const bool select_mode);
|
||||
|
||||
lua_State *luaState;
|
||||
std::string luaAction;
|
||||
std::string luaId;
|
||||
neutrino_locale_t name;
|
||||
std::string nameString;
|
||||
|
||||
public:
|
||||
bool active;
|
||||
bool active;
|
||||
bool marked;
|
||||
bool inert;
|
||||
bool isStatic;
|
||||
neutrino_msg_t directKey;
|
||||
neutrino_msg_t msg;
|
||||
std::string iconName;
|
||||
std::string selected_iconName;
|
||||
std::string iconName_Info_right;
|
||||
std::string iconName;
|
||||
std::string selected_iconName;
|
||||
std::string iconName_Info_right;
|
||||
std::string hintIcon;
|
||||
std::string hintText;
|
||||
neutrino_locale_t hint;
|
||||
|
||||
CMenuItem();
|
||||
@@ -130,6 +144,8 @@ class CMenuItem
|
||||
return 0;
|
||||
}
|
||||
virtual void setActive(const bool Active);
|
||||
virtual void setMarked(const bool Marked);
|
||||
virtual void setInert(const bool Inert);
|
||||
|
||||
virtual void paintItemButton(const bool select_mode, const int &item_height, const std::string& icon_Name = NEUTRINO_ICON_BUTTON_RIGHT);
|
||||
|
||||
@@ -144,54 +160,42 @@ class CMenuItem
|
||||
virtual void paintItemSlider( const bool select_mode, const int &item_height, const int &optionvalue, const int &factor, const char * left_text=NULL, const char * right_text=NULL);
|
||||
|
||||
virtual int isMenueOptionChooser(void) const{return 0;}
|
||||
void setHint(std::string icon, neutrino_locale_t text) { hintIcon = icon; hint = text; }
|
||||
void setHint(const std::string icon, const neutrino_locale_t text) { hintIcon = icon; hint = text; }
|
||||
void setHint(const std::string icon, const std::string text) { hintIcon = icon; hintText = text; }
|
||||
|
||||
void setLua(lua_State *_luaState, std::string &_luaAction, std::string &_luaId) { luaState = _luaState; luaAction = _luaAction; luaId = _luaId; };
|
||||
|
||||
virtual const char *getName();
|
||||
};
|
||||
|
||||
class CMenuSeparator : public CMenuItem
|
||||
{
|
||||
int type;
|
||||
std::string separator_text;
|
||||
int type;
|
||||
|
||||
public:
|
||||
neutrino_locale_t text;
|
||||
|
||||
enum
|
||||
{
|
||||
EMPTY = 0,
|
||||
LINE = 1,
|
||||
STRING = 2,
|
||||
ALIGN_CENTER = 4,
|
||||
ALIGN_LEFT = 8,
|
||||
ALIGN_RIGHT = 16,
|
||||
SUB_HEAD = 32
|
||||
EMPTY = 0,
|
||||
LINE = 1,
|
||||
STRING = 2,
|
||||
ALIGN_CENTER = 4,
|
||||
ALIGN_LEFT = 8,
|
||||
ALIGN_RIGHT = 16,
|
||||
SUB_HEAD = 32
|
||||
};
|
||||
|
||||
|
||||
CMenuSeparator(const int Type = 0, const neutrino_locale_t Text = NONEXISTANT_LOCALE, bool IsStatic = false);
|
||||
CMenuSeparator(const int Type, const std::string Text, bool IsStatic = false);
|
||||
virtual ~CMenuSeparator(){}
|
||||
|
||||
int paint(bool selected=false);
|
||||
int getHeight(void) const;
|
||||
int getWidth(void);
|
||||
|
||||
virtual const char * getString(void);
|
||||
void setString(const std::string& text);
|
||||
};
|
||||
|
||||
class CNonLocalizedMenuSeparator : public CMenuSeparator
|
||||
{
|
||||
const char * the_text;
|
||||
|
||||
public:
|
||||
CNonLocalizedMenuSeparator(const char * ptext, const neutrino_locale_t Text1) : CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, Text1)
|
||||
{
|
||||
the_text = ptext;
|
||||
}
|
||||
|
||||
virtual const char * getString(void)
|
||||
{
|
||||
return the_text;
|
||||
}
|
||||
void setName(const std::string& text);
|
||||
void setName(const neutrino_locale_t text);
|
||||
};
|
||||
|
||||
class CMenuForwarder : public CMenuItem
|
||||
|
Reference in New Issue
Block a user