|
|
@ -43,9 +43,9 @@ namespace NLGUI
|
|
|
|
void force_link_dbgroup_combo_box_cpp() { }
|
|
|
|
void force_link_dbgroup_combo_box_cpp() { }
|
|
|
|
|
|
|
|
|
|
|
|
// Compare strings
|
|
|
|
// Compare strings
|
|
|
|
static inline bool lt_text(const std::pair<int,ucstring> &s1, const std::pair<int,ucstring> &s2)
|
|
|
|
static inline bool lt_text(const std::pair<int,std::string> &s1, const std::pair<int,std::string> &s2)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return toLower(s1.second) < toLower(s2.second);
|
|
|
|
return toLowerAsUtf8(s1.second) < toLowerAsUtf8(s2.second);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::string CDBGroupComboBox::measureMenu;
|
|
|
|
std::string CDBGroupComboBox::measureMenu;
|
|
|
@ -183,10 +183,10 @@ namespace NLGUI
|
|
|
|
if (name)
|
|
|
|
if (name)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const char *propPtr = name;
|
|
|
|
const char *propPtr = name;
|
|
|
|
ucstring Text = ucstring::makeFromUtf8(propPtr);
|
|
|
|
if (NLMISC::startsWith(propPtr, "ui"))
|
|
|
|
if ((strlen(propPtr)>2) && (propPtr[0] == 'u') && (propPtr[1] == 'i'))
|
|
|
|
addText(CI18N::get(propPtr).toUtf8());
|
|
|
|
Text = CI18N::get (propPtr);
|
|
|
|
else
|
|
|
|
addText(Text);
|
|
|
|
addText(propPtr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
child = child->next;
|
|
|
|
child = child->next;
|
|
|
@ -240,11 +240,11 @@ namespace NLGUI
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(_IsExternViewText)
|
|
|
|
else if(_IsExternViewText)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_ViewText->setText(_ExternViewText.toUtf8());
|
|
|
|
_ViewText->setText(_ExternViewText);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_ViewText->setText(_Texts[_CacheSelection].second.toUtf8());
|
|
|
|
_ViewText->setText(_Texts[_CacheSelection].second);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -274,7 +274,7 @@ namespace NLGUI
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
void CDBGroupComboBox::addText(const ucstring &text)
|
|
|
|
void CDBGroupComboBox::addText(const std::string &text)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
dirt();
|
|
|
|
dirt();
|
|
|
|
_Texts.push_back(make_pair((uint)_Texts.size(), text));
|
|
|
|
_Texts.push_back(make_pair((uint)_Texts.size(), text));
|
|
|
@ -283,7 +283,7 @@ namespace NLGUI
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
void CDBGroupComboBox::setText(uint i, const ucstring &text)
|
|
|
|
void CDBGroupComboBox::setText(uint i, const std::string &text)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
dirt();
|
|
|
|
dirt();
|
|
|
|
if(i<_Texts.size())
|
|
|
|
if(i<_Texts.size())
|
|
|
@ -291,7 +291,7 @@ namespace NLGUI
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
void CDBGroupComboBox::insertText(uint i, const ucstring &text)
|
|
|
|
void CDBGroupComboBox::insertText(uint i, const std::string &text)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
dirt();
|
|
|
|
dirt();
|
|
|
|
if(i<_Texts.size())
|
|
|
|
if(i<_Texts.size())
|
|
|
@ -313,7 +313,7 @@ namespace NLGUI
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
void CDBGroupComboBox::setTexture(uint i, const ucstring &texture)
|
|
|
|
void CDBGroupComboBox::setTexture(uint i, const std::string &texture)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
dirt();
|
|
|
|
dirt();
|
|
|
|
if(i<_Textures.size())
|
|
|
|
if(i<_Textures.size())
|
|
|
@ -351,13 +351,19 @@ namespace NLGUI
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
const ucstring &CDBGroupComboBox::getText(uint i) const
|
|
|
|
const std::string &CDBGroupComboBox::getText(uint i) const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
static ucstring null;
|
|
|
|
static const std::string empty;
|
|
|
|
if(i<_Texts.size())
|
|
|
|
if (i < _Texts.size())
|
|
|
|
return _Texts[i].second;
|
|
|
|
return _Texts[i].second;
|
|
|
|
else
|
|
|
|
else
|
|
|
|
return null;
|
|
|
|
return empty;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
ucstring CDBGroupComboBox::getTextAsUtf16(uint i) const
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return ucstring::makeFromUtf8(getText(i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
@ -385,15 +391,21 @@ namespace NLGUI
|
|
|
|
{
|
|
|
|
{
|
|
|
|
sort(_Texts.begin(), _Texts.end(), lt_text);
|
|
|
|
sort(_Texts.begin(), _Texts.end(), lt_text);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
const ucstring &CDBGroupComboBox::getTexture(uint i) const
|
|
|
|
const std::string &CDBGroupComboBox::getTexture(uint i) const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
static ucstring null;
|
|
|
|
static const std::string empty;
|
|
|
|
if(i<_Textures.size())
|
|
|
|
if (i < _Textures.size())
|
|
|
|
return _Textures[i];
|
|
|
|
return _Textures[i];
|
|
|
|
else
|
|
|
|
else
|
|
|
|
return null;
|
|
|
|
return empty;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
ucstring CDBGroupComboBox::getTextureAsUtf16(uint i) const
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return ucstring::makeFromUtf8(getTexture(i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
@ -452,8 +464,7 @@ namespace NLGUI
|
|
|
|
sint32 value;
|
|
|
|
sint32 value;
|
|
|
|
for(uint i=0; i<getNumTexts(); i++)
|
|
|
|
for(uint i=0; i<getNumTexts(); i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::string sText;
|
|
|
|
std::string sText = getText(i);
|
|
|
|
getText(i).toString(sText);
|
|
|
|
|
|
|
|
if(sText == val)
|
|
|
|
if(sText == val)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
value = i;
|
|
|
|
value = i;
|
|
|
@ -464,15 +475,21 @@ namespace NLGUI
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
void CDBGroupComboBox::setViewText(const ucstring & text)
|
|
|
|
void CDBGroupComboBox::setViewText(const std::string &text)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_IsExternViewText = true;
|
|
|
|
_IsExternViewText = true;
|
|
|
|
_ExternViewText = text;
|
|
|
|
_ExternViewText = text;
|
|
|
|
_ViewText->setText(_ExternViewText.toUtf8());
|
|
|
|
_ViewText->setText(_ExternViewText);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
ucstring CDBGroupComboBox::getViewText() const
|
|
|
|
std::string CDBGroupComboBox::getViewText() const
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return _ViewText->getText();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
ucstring CDBGroupComboBox::getViewTextAsUtf16() const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return CUtfStringView(_ViewText->getText()).toUtf16();
|
|
|
|
return CUtfStringView(_ViewText->getText()).toUtf16();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -486,18 +503,14 @@ namespace NLGUI
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
std::string CDBGroupComboBox::getSelectionText() const
|
|
|
|
std::string CDBGroupComboBox::getSelectionText() const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ucstring text;
|
|
|
|
|
|
|
|
if (_LinkedToDB)
|
|
|
|
if (_LinkedToDB)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
text = getText(_Selection.getSInt32());
|
|
|
|
return getText(_Selection.getSInt32());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
text = getText(_NotLinkedToDBSelection);
|
|
|
|
return getText(_NotLinkedToDBSelection);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
std::string texteS;
|
|
|
|
|
|
|
|
text.toString(texteS);
|
|
|
|
|
|
|
|
return texteS;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
@ -538,8 +551,7 @@ namespace NLGUI
|
|
|
|
sint32 value;
|
|
|
|
sint32 value;
|
|
|
|
for(uint i=0; i<getNumTexts(); i++)
|
|
|
|
for(uint i=0; i<getNumTexts(); i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::string sText;
|
|
|
|
std::string sText = getText(i);
|
|
|
|
getText(i).toString(sText);
|
|
|
|
|
|
|
|
if(sText == text)
|
|
|
|
if(sText == text)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
value = i;
|
|
|
|
value = i;
|
|
|
@ -566,7 +578,7 @@ namespace NLGUI
|
|
|
|
CLuaIHM::checkArgTypeUCString(ls, funcName, 1);
|
|
|
|
CLuaIHM::checkArgTypeUCString(ls, funcName, 1);
|
|
|
|
ucstring text;
|
|
|
|
ucstring text;
|
|
|
|
nlverify(CLuaIHM::pop(ls, text));
|
|
|
|
nlverify(CLuaIHM::pop(ls, text));
|
|
|
|
addText(text);
|
|
|
|
addText(text.toUtf8()); // FIXME: Lua should just do UTF-8!
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -579,7 +591,7 @@ namespace NLGUI
|
|
|
|
CLuaIHM::checkArgTypeUCString(ls, funcName, 2);
|
|
|
|
CLuaIHM::checkArgTypeUCString(ls, funcName, 2);
|
|
|
|
ucstring text;
|
|
|
|
ucstring text;
|
|
|
|
nlverify(CLuaIHM::pop(ls, text));
|
|
|
|
nlverify(CLuaIHM::pop(ls, text));
|
|
|
|
setText((uint) ls.toInteger(1), text);
|
|
|
|
setText((uint) ls.toInteger(1), text.toUtf8()); // FIXME: Lua should just do UTF-8!
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -592,7 +604,7 @@ namespace NLGUI
|
|
|
|
CLuaIHM::checkArgTypeUCString(ls, funcName, 2);
|
|
|
|
CLuaIHM::checkArgTypeUCString(ls, funcName, 2);
|
|
|
|
ucstring text;
|
|
|
|
ucstring text;
|
|
|
|
nlverify(CLuaIHM::pop(ls, text));
|
|
|
|
nlverify(CLuaIHM::pop(ls, text));
|
|
|
|
insertText((uint) ls.toInteger(1), text);
|
|
|
|
insertText((uint) ls.toInteger(1), text.toUtf8()); // FIXME: Lua should just do UTF-8!
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -605,7 +617,7 @@ namespace NLGUI
|
|
|
|
CLuaIHM::checkArgTypeUCString(ls, funcName, 2);
|
|
|
|
CLuaIHM::checkArgTypeUCString(ls, funcName, 2);
|
|
|
|
ucstring texture;
|
|
|
|
ucstring texture;
|
|
|
|
nlverify(CLuaIHM::pop(ls, texture));
|
|
|
|
nlverify(CLuaIHM::pop(ls, texture));
|
|
|
|
setTexture((uint) ls.toInteger(1), texture);
|
|
|
|
setTexture((uint) ls.toInteger(1), texture.toUtf8()); // FIXME: Lua should just do UTF-8!
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -625,7 +637,7 @@ namespace NLGUI
|
|
|
|
const char *funcName = "removeText";
|
|
|
|
const char *funcName = "removeText";
|
|
|
|
CLuaIHM::checkArgCount(ls, funcName, 1);
|
|
|
|
CLuaIHM::checkArgCount(ls, funcName, 1);
|
|
|
|
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
|
|
|
|
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
|
|
|
|
removeText((uint) ls.toInteger(1));
|
|
|
|
removeText((uint)ls.toInteger(1));
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -652,12 +664,12 @@ namespace NLGUI
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// set the id as the parameter
|
|
|
|
// set the id as the parameter
|
|
|
|
bool checkable = false;
|
|
|
|
bool checkable = false;
|
|
|
|
if(getTexture(i).toString() != std::string())
|
|
|
|
if (getTexture(i) != std::string())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
checkable = true;
|
|
|
|
checkable = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
groupMenu->addLine(getText(i), "combo_box_select_end", toString(i),
|
|
|
|
groupMenu->addLine(ucstring::makeFromUtf8(getText(i)), "combo_box_select_end", toString(i),
|
|
|
|
"", std::string(), getTexture(i).toString(), checkable);
|
|
|
|
"", std::string(), getTexture(i), checkable);
|
|
|
|
groupMenu->setGrayedLine(i, getGrayed(i));
|
|
|
|
groupMenu->setGrayedLine(i, getGrayed(i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|