|
|
|
@ -43,9 +43,9 @@ namespace NLGUI
|
|
|
|
|
void force_link_dbgroup_combo_box_cpp() { }
|
|
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
@ -183,10 +183,10 @@ namespace NLGUI
|
|
|
|
|
if (name)
|
|
|
|
|
{
|
|
|
|
|
const char *propPtr = name;
|
|
|
|
|
ucstring Text = ucstring::makeFromUtf8(propPtr);
|
|
|
|
|
if ((strlen(propPtr)>2) && (propPtr[0] == 'u') && (propPtr[1] == 'i'))
|
|
|
|
|
Text = CI18N::get (propPtr);
|
|
|
|
|
addText(Text);
|
|
|
|
|
if (NLMISC::startsWith(propPtr, "ui"))
|
|
|
|
|
addText(CI18N::get(propPtr).toUtf8());
|
|
|
|
|
else
|
|
|
|
|
addText(propPtr);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
child = child->next;
|
|
|
|
@ -240,11 +240,11 @@ namespace NLGUI
|
|
|
|
|
}
|
|
|
|
|
else if(_IsExternViewText)
|
|
|
|
|
{
|
|
|
|
|
_ViewText->setText(_ExternViewText.toUtf8());
|
|
|
|
|
_ViewText->setText(_ExternViewText);
|
|
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
|
_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();
|
|
|
|
|
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();
|
|
|
|
|
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();
|
|
|
|
|
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;
|
|
|
|
|
if(i<_Texts.size())
|
|
|
|
|
static const std::string empty;
|
|
|
|
|
if (i < _Texts.size())
|
|
|
|
|
return _Texts[i].second;
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
const ucstring &CDBGroupComboBox::getTexture(uint i) const
|
|
|
|
|
const std::string &CDBGroupComboBox::getTexture(uint i) const
|
|
|
|
|
{
|
|
|
|
|
static ucstring null;
|
|
|
|
|
if(i<_Textures.size())
|
|
|
|
|
static const std::string empty;
|
|
|
|
|
if (i < _Textures.size())
|
|
|
|
|
return _Textures[i];
|
|
|
|
|
else
|
|
|
|
|
return null;
|
|
|
|
|
return empty;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
ucstring CDBGroupComboBox::getTextureAsUtf16(uint i) const
|
|
|
|
|
{
|
|
|
|
|
return ucstring::makeFromUtf8(getTexture(i));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
@ -452,8 +464,7 @@ namespace NLGUI
|
|
|
|
|
sint32 value;
|
|
|
|
|
for(uint i=0; i<getNumTexts(); i++)
|
|
|
|
|
{
|
|
|
|
|
std::string sText;
|
|
|
|
|
getText(i).toString(sText);
|
|
|
|
|
std::string sText = getText(i);
|
|
|
|
|
if(sText == val)
|
|
|
|
|
{
|
|
|
|
|
value = i;
|
|
|
|
@ -464,15 +475,21 @@ namespace NLGUI
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
void CDBGroupComboBox::setViewText(const ucstring & text)
|
|
|
|
|
void CDBGroupComboBox::setViewText(const std::string &text)
|
|
|
|
|
{
|
|
|
|
|
_IsExternViewText = true;
|
|
|
|
|
_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();
|
|
|
|
|
}
|
|
|
|
@ -486,18 +503,14 @@ namespace NLGUI
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
std::string CDBGroupComboBox::getSelectionText() const
|
|
|
|
|
{
|
|
|
|
|
ucstring text;
|
|
|
|
|
if (_LinkedToDB)
|
|
|
|
|
{
|
|
|
|
|
text = getText(_Selection.getSInt32());
|
|
|
|
|
return getText(_Selection.getSInt32());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
text = getText(_NotLinkedToDBSelection);
|
|
|
|
|
return getText(_NotLinkedToDBSelection);
|
|
|
|
|
}
|
|
|
|
|
std::string texteS;
|
|
|
|
|
text.toString(texteS);
|
|
|
|
|
return texteS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
@ -538,8 +551,7 @@ namespace NLGUI
|
|
|
|
|
sint32 value;
|
|
|
|
|
for(uint i=0; i<getNumTexts(); i++)
|
|
|
|
|
{
|
|
|
|
|
std::string sText;
|
|
|
|
|
getText(i).toString(sText);
|
|
|
|
|
std::string sText = getText(i);
|
|
|
|
|
if(sText == text)
|
|
|
|
|
{
|
|
|
|
|
value = i;
|
|
|
|
@ -566,7 +578,7 @@ namespace NLGUI
|
|
|
|
|
CLuaIHM::checkArgTypeUCString(ls, funcName, 1);
|
|
|
|
|
ucstring text;
|
|
|
|
|
nlverify(CLuaIHM::pop(ls, text));
|
|
|
|
|
addText(text);
|
|
|
|
|
addText(text.toUtf8()); // FIXME: Lua should just do UTF-8!
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -579,7 +591,7 @@ namespace NLGUI
|
|
|
|
|
CLuaIHM::checkArgTypeUCString(ls, funcName, 2);
|
|
|
|
|
ucstring 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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -592,7 +604,7 @@ namespace NLGUI
|
|
|
|
|
CLuaIHM::checkArgTypeUCString(ls, funcName, 2);
|
|
|
|
|
ucstring 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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -605,7 +617,7 @@ namespace NLGUI
|
|
|
|
|
CLuaIHM::checkArgTypeUCString(ls, funcName, 2);
|
|
|
|
|
ucstring 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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -625,7 +637,7 @@ namespace NLGUI
|
|
|
|
|
const char *funcName = "removeText";
|
|
|
|
|
CLuaIHM::checkArgCount(ls, funcName, 1);
|
|
|
|
|
CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER);
|
|
|
|
|
removeText((uint) ls.toInteger(1));
|
|
|
|
|
removeText((uint)ls.toInteger(1));
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -652,12 +664,12 @@ namespace NLGUI
|
|
|
|
|
{
|
|
|
|
|
// set the id as the parameter
|
|
|
|
|
bool checkable = false;
|
|
|
|
|
if(getTexture(i).toString() != std::string())
|
|
|
|
|
if (getTexture(i) != std::string())
|
|
|
|
|
{
|
|
|
|
|
checkable = true;
|
|
|
|
|
}
|
|
|
|
|
groupMenu->addLine(getText(i), "combo_box_select_end", toString(i),
|
|
|
|
|
"", std::string(), getTexture(i).toString(), checkable);
|
|
|
|
|
groupMenu->addLine(ucstring::makeFromUtf8(getText(i)), "combo_box_select_end", toString(i),
|
|
|
|
|
"", std::string(), getTexture(i), checkable);
|
|
|
|
|
groupMenu->setGrayedLine(i, getGrayed(i));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|