|
|
@ -3,6 +3,7 @@
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// This source file has been modified by the following contributors:
|
|
|
|
// This source file has been modified by the following contributors:
|
|
|
|
// Copyright (C) 2013-2014 Laszlo KIS-ADAM (dfighter) <dfighter1985@gmail.com>
|
|
|
|
// Copyright (C) 2013-2014 Laszlo KIS-ADAM (dfighter) <dfighter1985@gmail.com>
|
|
|
|
|
|
|
|
// Copyright (C) 2020 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Affero General Public License as
|
|
|
|
// it under the terms of the GNU Affero General Public License as
|
|
|
@ -21,6 +22,7 @@
|
|
|
|
#include "stdpch.h"
|
|
|
|
#include "stdpch.h"
|
|
|
|
#include "nel/gui/group_editbox.h"
|
|
|
|
#include "nel/gui/group_editbox.h"
|
|
|
|
#include "nel/misc/command.h"
|
|
|
|
#include "nel/misc/command.h"
|
|
|
|
|
|
|
|
#include "nel/misc/utf_string_view.h"
|
|
|
|
#include "nel/gui/view_text.h"
|
|
|
|
#include "nel/gui/view_text.h"
|
|
|
|
#include "nel/misc/xml_auto_ptr.h"
|
|
|
|
#include "nel/misc/xml_auto_ptr.h"
|
|
|
|
#include "nel/gui/interface_options.h"
|
|
|
|
#include "nel/gui/interface_options.h"
|
|
|
@ -95,7 +97,7 @@ namespace NLGUI
|
|
|
|
_ViewTextDeltaX(0)
|
|
|
|
_ViewTextDeltaX(0)
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_Prompt = ">";
|
|
|
|
_Prompt = ::u32string(1, (u32char)'>');
|
|
|
|
_BackSelectColor= CRGBA::White;
|
|
|
|
_BackSelectColor= CRGBA::White;
|
|
|
|
_TextSelectColor= CRGBA::Black;
|
|
|
|
_TextSelectColor= CRGBA::Black;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -169,7 +171,7 @@ namespace NLGUI
|
|
|
|
else
|
|
|
|
else
|
|
|
|
if( name == "prompt" )
|
|
|
|
if( name == "prompt" )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return _Prompt.toString();
|
|
|
|
return CUtfStringView(_Prompt).toUtf8();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
if( name == "enter_type" )
|
|
|
|
if( name == "enter_type" )
|
|
|
@ -263,9 +265,9 @@ namespace NLGUI
|
|
|
|
std::string s;
|
|
|
|
std::string s;
|
|
|
|
s.reserve( _NegativeFilter.size() );
|
|
|
|
s.reserve( _NegativeFilter.size() );
|
|
|
|
|
|
|
|
|
|
|
|
std::vector< char >::const_iterator itr;
|
|
|
|
std::vector< u32char >::const_iterator itr;
|
|
|
|
for( itr = _NegativeFilter.begin(); itr != _NegativeFilter.end(); ++itr )
|
|
|
|
for (itr = _NegativeFilter.begin(); itr != _NegativeFilter.end(); ++itr)
|
|
|
|
s.push_back( *itr );
|
|
|
|
CUtfStringView::append(s, *itr);
|
|
|
|
|
|
|
|
|
|
|
|
return s;
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -353,7 +355,7 @@ namespace NLGUI
|
|
|
|
else
|
|
|
|
else
|
|
|
|
if( name == "prompt" )
|
|
|
|
if( name == "prompt" )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_Prompt = value;
|
|
|
|
_Prompt = CUtfStringView(value).toUtf32();
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
@ -449,10 +451,10 @@ namespace NLGUI
|
|
|
|
if( name == "negative_filter" )
|
|
|
|
if( name == "negative_filter" )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_NegativeFilter.clear();
|
|
|
|
_NegativeFilter.clear();
|
|
|
|
|
|
|
|
::u32string::size_type i;
|
|
|
|
std::string::size_type i;
|
|
|
|
::u32string ustr = CUtfStringView(value).toUtf32();
|
|
|
|
for( i = 0; i < value.size(); i++ )
|
|
|
|
for( i = 0; i < ustr.size(); i++ )
|
|
|
|
_NegativeFilter.push_back( value[ i ] );
|
|
|
|
_NegativeFilter.push_back(ustr[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
CInterfaceGroup::setProperty( name, value );
|
|
|
|
CInterfaceGroup::setProperty( name, value );
|
|
|
@ -476,7 +478,7 @@ namespace NLGUI
|
|
|
|
xmlSetProp( node, BAD_CAST "max_chars_size", BAD_CAST toString( _MaxCharsSize ).c_str() );
|
|
|
|
xmlSetProp( node, BAD_CAST "max_chars_size", BAD_CAST toString( _MaxCharsSize ).c_str() );
|
|
|
|
xmlSetProp( node, BAD_CAST "enter_loose_focus", BAD_CAST toString( _LooseFocusOnEnter ).c_str() );
|
|
|
|
xmlSetProp( node, BAD_CAST "enter_loose_focus", BAD_CAST toString( _LooseFocusOnEnter ).c_str() );
|
|
|
|
xmlSetProp( node, BAD_CAST "enter_recover_focus", BAD_CAST toString( _RecoverFocusOnEnter ).c_str() );
|
|
|
|
xmlSetProp( node, BAD_CAST "enter_recover_focus", BAD_CAST toString( _RecoverFocusOnEnter ).c_str() );
|
|
|
|
xmlSetProp( node, BAD_CAST "prompt", BAD_CAST _Prompt.toString().c_str() );
|
|
|
|
xmlSetProp( node, BAD_CAST "prompt", BAD_CAST CUtfStringView(_Prompt).toUtf8().c_str() );
|
|
|
|
|
|
|
|
|
|
|
|
std::string e;
|
|
|
|
std::string e;
|
|
|
|
switch( _EntryType )
|
|
|
|
switch( _EntryType )
|
|
|
@ -538,9 +540,9 @@ namespace NLGUI
|
|
|
|
std::string s;
|
|
|
|
std::string s;
|
|
|
|
s.reserve( _NegativeFilter.size() );
|
|
|
|
s.reserve( _NegativeFilter.size() );
|
|
|
|
|
|
|
|
|
|
|
|
std::vector< char >::const_iterator itr;
|
|
|
|
std::vector< u32char >::const_iterator itr;
|
|
|
|
for( itr = _NegativeFilter.begin(); itr != _NegativeFilter.end(); ++itr )
|
|
|
|
for( itr = _NegativeFilter.begin(); itr != _NegativeFilter.end(); ++itr )
|
|
|
|
s.push_back( *itr );
|
|
|
|
CUtfStringView::append(s, *itr);
|
|
|
|
|
|
|
|
|
|
|
|
xmlSetProp( node, BAD_CAST "negative_filter", BAD_CAST s.c_str() );
|
|
|
|
xmlSetProp( node, BAD_CAST "negative_filter", BAD_CAST s.c_str() );
|
|
|
|
|
|
|
|
|
|
|
@ -605,7 +607,7 @@ namespace NLGUI
|
|
|
|
if (prop) _ResetFocusOnHide = convertBool(prop);
|
|
|
|
if (prop) _ResetFocusOnHide = convertBool(prop);
|
|
|
|
|
|
|
|
|
|
|
|
prop = (char*) xmlGetProp( cur, (xmlChar*)"prompt" );
|
|
|
|
prop = (char*) xmlGetProp( cur, (xmlChar*)"prompt" );
|
|
|
|
if (prop) _Prompt = (const char*)prop;
|
|
|
|
if (prop) _Prompt = CUtfStringView((const char*)prop).toUtf32();
|
|
|
|
|
|
|
|
|
|
|
|
prop = (char*) xmlGetProp( cur, (xmlChar*)"entry_type" );
|
|
|
|
prop = (char*) xmlGetProp( cur, (xmlChar*)"entry_type" );
|
|
|
|
_EntryType = Text;
|
|
|
|
_EntryType = Text;
|
|
|
@ -656,9 +658,11 @@ namespace NLGUI
|
|
|
|
prop = (char*) xmlGetProp( cur, (xmlChar*)"negative_filter" );
|
|
|
|
prop = (char*) xmlGetProp( cur, (xmlChar*)"negative_filter" );
|
|
|
|
if (prop)
|
|
|
|
if (prop)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
uint length = (uint)strlen(prop);
|
|
|
|
_NegativeFilter.clear();
|
|
|
|
_NegativeFilter.resize(length);
|
|
|
|
::u32string::size_type i;
|
|
|
|
std::copy((const char *) prop, (const char *) prop + length, _NegativeFilter.begin());
|
|
|
|
::u32string ustr = CUtfStringView(prop).toUtf32();
|
|
|
|
|
|
|
|
for( i = 0; i < ustr.size(); i++ )
|
|
|
|
|
|
|
|
_NegativeFilter.push_back(ustr[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
@ -802,7 +806,7 @@ namespace NLGUI
|
|
|
|
cutSelection();
|
|
|
|
cutSelection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ucstring sString;
|
|
|
|
string sString;
|
|
|
|
|
|
|
|
|
|
|
|
if (CViewRenderer::getInstance()->getDriver()->pasteTextFromClipboard(sString))
|
|
|
|
if (CViewRenderer::getInstance()->getDriver()->pasteTextFromClipboard(sString))
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -812,7 +816,7 @@ namespace NLGUI
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
void CGroupEditBox::appendStringFromClipboard(const ucstring &str)
|
|
|
|
void CGroupEditBox::appendStringFromClipboard(const std::string &str)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
stopParentBlink();
|
|
|
|
stopParentBlink();
|
|
|
|
makeTopWindow();
|
|
|
|
makeTopWindow();
|
|
|
@ -826,11 +830,12 @@ namespace NLGUI
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
void CGroupEditBox::writeString(const ucstring &str, bool replace, bool atEnd)
|
|
|
|
void CGroupEditBox::writeString(const std::string &str16, bool replace, bool atEnd)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
::u32string str = CUtfStringView(str16).toUtf32();
|
|
|
|
sint length = (sint)str.length();
|
|
|
|
sint length = (sint)str.length();
|
|
|
|
|
|
|
|
|
|
|
|
ucstring toAppend;
|
|
|
|
::u32string toAppend;
|
|
|
|
// filter character depending on the entry type
|
|
|
|
// filter character depending on the entry type
|
|
|
|
switch (_EntryType)
|
|
|
|
switch (_EntryType)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -852,7 +857,7 @@ namespace NLGUI
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// remove '\r' characters
|
|
|
|
// remove '\r' characters
|
|
|
|
toAppend.erase(std::remove(toAppend.begin(), toAppend.end(), (ucchar) '\r'), toAppend.end());
|
|
|
|
toAppend.erase(std::remove(toAppend.begin(), toAppend.end(), (u32char) '\r'), toAppend.end());
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
@ -963,7 +968,7 @@ namespace NLGUI
|
|
|
|
{
|
|
|
|
{
|
|
|
|
length = _MaxNumChar - (sint)_InputString.length();
|
|
|
|
length = _MaxNumChar - (sint)_InputString.length();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ucstring toAdd = toAppend.substr(0, length);
|
|
|
|
::u32string toAdd = toAppend.substr(0, length);
|
|
|
|
sint32 minPos;
|
|
|
|
sint32 minPos;
|
|
|
|
sint32 maxPos;
|
|
|
|
sint32 maxPos;
|
|
|
|
if (_CurrSelection == this)
|
|
|
|
if (_CurrSelection == this)
|
|
|
@ -1013,7 +1018,7 @@ namespace NLGUI
|
|
|
|
_CursorAtPreviousLineEnd = false;
|
|
|
|
_CursorAtPreviousLineEnd = false;
|
|
|
|
if (_ClearOnEscape)
|
|
|
|
if (_ClearOnEscape)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
setInputString(ucstring(""));
|
|
|
|
setInputStringAsUtf32(::u32string());
|
|
|
|
triggerOnChangeAH();
|
|
|
|
triggerOnChangeAH();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
CWidgetManager::getInstance()->setCaptureKeyboard(NULL);
|
|
|
|
CWidgetManager::getInstance()->setCaptureKeyboard(NULL);
|
|
|
@ -1059,8 +1064,9 @@ namespace NLGUI
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (isKeyRETURN)
|
|
|
|
if (isKeyRETURN)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ucstring copyStr= _InputString;
|
|
|
|
//ucstring copyStr= _InputString;
|
|
|
|
if ((uint) std::count(copyStr.begin(), copyStr.end(), '\n') >= _MaxNumReturn)
|
|
|
|
//if ((uint) std::count(copyStr.begin(), copyStr.end(), '\n') >= _MaxNumReturn)
|
|
|
|
|
|
|
|
if ((uint)std::count(_InputString.begin(), _InputString.end(), '\n') >= _MaxNumReturn)
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1074,7 +1080,7 @@ namespace NLGUI
|
|
|
|
cutSelection();
|
|
|
|
cutSelection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ucchar c = isKeyRETURN ? '\n' : rEDK.getChar();
|
|
|
|
u32char c = isKeyRETURN ? '\n' : rEDK.getChar();
|
|
|
|
if (isFiltered(c)) return;
|
|
|
|
if (isFiltered(c)) return;
|
|
|
|
switch(_EntryType)
|
|
|
|
switch(_EntryType)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -1121,11 +1127,11 @@ namespace NLGUI
|
|
|
|
if(_EntryType==Integer && (_IntegerMinValue!=INT_MIN || _IntegerMaxValue!=INT_MAX))
|
|
|
|
if(_EntryType==Integer && (_IntegerMinValue!=INT_MIN || _IntegerMaxValue!=INT_MAX))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// estimate new string
|
|
|
|
// estimate new string
|
|
|
|
ucstring copyStr= _InputString;
|
|
|
|
::u32string copyStr= _InputString;
|
|
|
|
ucstring::iterator it = copyStr.begin() + _CursorPos;
|
|
|
|
::u32string::iterator it = copyStr.begin() + _CursorPos;
|
|
|
|
copyStr.insert(it, c);
|
|
|
|
copyStr.insert(it, c);
|
|
|
|
sint32 value;
|
|
|
|
sint32 value;
|
|
|
|
fromString(copyStr.toString(), value);
|
|
|
|
fromString(CUtfStringView(copyStr).toUtf8(), value);
|
|
|
|
// if out of bounds, abort char
|
|
|
|
// if out of bounds, abort char
|
|
|
|
if(value<_IntegerMinValue || value>_IntegerMaxValue)
|
|
|
|
if(value<_IntegerMinValue || value>_IntegerMaxValue)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -1134,12 +1140,12 @@ namespace NLGUI
|
|
|
|
if(_EntryType==PositiveInteger && (_PositiveIntegerMinValue!=0 || _PositiveIntegerMaxValue!=UINT_MAX))
|
|
|
|
if(_EntryType==PositiveInteger && (_PositiveIntegerMinValue!=0 || _PositiveIntegerMaxValue!=UINT_MAX))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// estimate new string
|
|
|
|
// estimate new string
|
|
|
|
ucstring copyStr= _InputString;
|
|
|
|
::u32string copyStr= _InputString;
|
|
|
|
ucstring::iterator it = copyStr.begin() + _CursorPos;
|
|
|
|
::u32string::iterator it = copyStr.begin() + _CursorPos;
|
|
|
|
copyStr.insert(it, c);
|
|
|
|
copyStr.insert(it, c);
|
|
|
|
// \todo yoyo: this doesn't really work i think....
|
|
|
|
// \todo yoyo: this doesn't really work i think....
|
|
|
|
uint32 value;
|
|
|
|
uint32 value;
|
|
|
|
fromString(copyStr.toString(), value);
|
|
|
|
fromString(CUtfStringView(copyStr).toUtf8(), value);
|
|
|
|
// if out of bounds, abort char
|
|
|
|
// if out of bounds, abort char
|
|
|
|
if(value<_PositiveIntegerMinValue || value>_PositiveIntegerMaxValue)
|
|
|
|
if(value<_PositiveIntegerMinValue || value>_PositiveIntegerMaxValue)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -1148,7 +1154,7 @@ namespace NLGUI
|
|
|
|
if ((uint) _InputString.length() < _MaxNumChar)
|
|
|
|
if ((uint) _InputString.length() < _MaxNumChar)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
makeTopWindow();
|
|
|
|
makeTopWindow();
|
|
|
|
ucstring::iterator it = _InputString.begin() + _CursorPos;
|
|
|
|
::u32string::iterator it = _InputString.begin() + _CursorPos;
|
|
|
|
_InputString.insert(it, c);
|
|
|
|
_InputString.insert(it, c);
|
|
|
|
++ _CursorPos;
|
|
|
|
++ _CursorPos;
|
|
|
|
triggerOnChangeAH();
|
|
|
|
triggerOnChangeAH();
|
|
|
@ -1176,7 +1182,7 @@ namespace NLGUI
|
|
|
|
if (CWidgetManager::getInstance()->getCaptureKeyboard() != this) return false;
|
|
|
|
if (CWidgetManager::getInstance()->getCaptureKeyboard() != this) return false;
|
|
|
|
if (!_CanUndo) return false;
|
|
|
|
if (!_CanUndo) return false;
|
|
|
|
_ModifiedInputString = _InputString;
|
|
|
|
_ModifiedInputString = _InputString;
|
|
|
|
setInputString(_StartInputString);
|
|
|
|
setInputStringAsUtf32(_StartInputString);
|
|
|
|
_CanUndo = false;
|
|
|
|
_CanUndo = false;
|
|
|
|
_CanRedo = true;
|
|
|
|
_CanRedo = true;
|
|
|
|
setCursorPos((sint32)_InputString.length());
|
|
|
|
setCursorPos((sint32)_InputString.length());
|
|
|
@ -1189,7 +1195,7 @@ namespace NLGUI
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (CWidgetManager::getInstance()->getCaptureKeyboard() != this) return false;
|
|
|
|
if (CWidgetManager::getInstance()->getCaptureKeyboard() != this) return false;
|
|
|
|
if (!_CanRedo) return false;
|
|
|
|
if (!_CanRedo) return false;
|
|
|
|
setInputString(_ModifiedInputString);
|
|
|
|
setInputStringAsUtf32(_ModifiedInputString);
|
|
|
|
_CanUndo = true;
|
|
|
|
_CanUndo = true;
|
|
|
|
_CanRedo = false;
|
|
|
|
_CanRedo = false;
|
|
|
|
setCursorPos((sint32)_InputString.length());
|
|
|
|
setCursorPos((sint32)_InputString.length());
|
|
|
@ -1229,11 +1235,11 @@ namespace NLGUI
|
|
|
|
{
|
|
|
|
{
|
|
|
|
makeTopWindow();
|
|
|
|
makeTopWindow();
|
|
|
|
// for french, deutsch and russian, be aware of unicode
|
|
|
|
// for french, deutsch and russian, be aware of unicode
|
|
|
|
std::string command = ucstring(_InputString.substr(1)).toUtf8();
|
|
|
|
std::string command = CUtfStringView(_InputString.substr(1)).toUtf8();
|
|
|
|
ICommand::expand(command);
|
|
|
|
ICommand::expand(command);
|
|
|
|
// then back to ucstring
|
|
|
|
// then back to u32string
|
|
|
|
_InputString.fromUtf8(command);
|
|
|
|
_InputString = CUtfStringView('/' + command).toUtf32();
|
|
|
|
_InputString = '/' + _InputString;
|
|
|
|
_InputString = _InputString;
|
|
|
|
_CursorPos = (sint32)_InputString.length();
|
|
|
|
_CursorPos = (sint32)_InputString.length();
|
|
|
|
_CursorAtPreviousLineEnd = false;
|
|
|
|
_CursorAtPreviousLineEnd = false;
|
|
|
|
triggerOnChangeAH();
|
|
|
|
triggerOnChangeAH();
|
|
|
@ -1260,7 +1266,7 @@ namespace NLGUI
|
|
|
|
// else delete last character
|
|
|
|
// else delete last character
|
|
|
|
else if(_InputString.size () > 0 && _CursorPos != 0)
|
|
|
|
else if(_InputString.size () > 0 && _CursorPos != 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ucstring::iterator it = _InputString.begin() + (_CursorPos - 1);
|
|
|
|
::u32string::iterator it = _InputString.begin() + (_CursorPos - 1);
|
|
|
|
_InputString.erase(it);
|
|
|
|
_InputString.erase(it);
|
|
|
|
-- _CursorPos;
|
|
|
|
-- _CursorPos;
|
|
|
|
_CursorAtPreviousLineEnd = false;
|
|
|
|
_CursorAtPreviousLineEnd = false;
|
|
|
@ -1300,7 +1306,7 @@ namespace NLGUI
|
|
|
|
default: break;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// update the text
|
|
|
|
// update the text
|
|
|
|
setInputString(_InputString);
|
|
|
|
setInputStringAsUtf32(_InputString);
|
|
|
|
|
|
|
|
|
|
|
|
// if event of type char or string, consider handle all of them
|
|
|
|
// if event of type char or string, consider handle all of them
|
|
|
|
if( rEDK.getKeyEventType()==NLGUI::CEventDescriptorKey::keychar || rEDK.getKeyEventType()==NLGUI::CEventDescriptorKey::keystring )
|
|
|
|
if( rEDK.getKeyEventType()==NLGUI::CEventDescriptorKey::keychar || rEDK.getKeyEventType()==NLGUI::CEventDescriptorKey::keystring )
|
|
|
@ -1430,16 +1436,14 @@ namespace NLGUI
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (_ViewText)
|
|
|
|
if (_ViewText)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ucstring usTmp;
|
|
|
|
std::string usTmp;
|
|
|
|
if (_EntryType == Password)
|
|
|
|
if (_EntryType == Password)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
usTmp = _Prompt;
|
|
|
|
usTmp = CUtfStringView(_Prompt + ::u32string(_InputString.size(), 0x2022)).toUtf8();
|
|
|
|
for (uint32 i = 0; i < _InputString.size(); ++i)
|
|
|
|
|
|
|
|
usTmp += "*";
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
usTmp = _Prompt + _InputString;
|
|
|
|
usTmp = CUtfStringView(_Prompt + _InputString).toUtf8();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_ViewText->setText (usTmp);
|
|
|
|
_ViewText->setText (usTmp);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1576,13 +1580,13 @@ namespace NLGUI
|
|
|
|
|
|
|
|
|
|
|
|
_ViewText->setParent( this );
|
|
|
|
_ViewText->setParent( this );
|
|
|
|
_ViewText->setIdRecurse( "edit_text" );
|
|
|
|
_ViewText->setIdRecurse( "edit_text" );
|
|
|
|
_ViewText->setHardText( "" );
|
|
|
|
_ViewText->setTextLocalized( "", false );
|
|
|
|
_ViewText->setPosRef( Hotspot_ML );
|
|
|
|
_ViewText->setPosRef( Hotspot_ML );
|
|
|
|
_ViewText->setParentPosRef( Hotspot_ML );
|
|
|
|
_ViewText->setParentPosRef( Hotspot_ML );
|
|
|
|
addView( _ViewText );
|
|
|
|
addView( _ViewText );
|
|
|
|
|
|
|
|
|
|
|
|
sint32 w,h;
|
|
|
|
sint32 w,h;
|
|
|
|
w = std::max( sint32( _ViewText->getFontWidth() * _ViewText->getText().size() ), getW() );
|
|
|
|
w = std::max( sint32( _ViewText->getFontWidth() * CUtfStringView(_ViewText->getText()).count() ), getW() );
|
|
|
|
h = std::max( sint32( _ViewText->getFontHeight() ), getH() );
|
|
|
|
h = std::max( sint32( _ViewText->getFontHeight() ), getH() );
|
|
|
|
|
|
|
|
|
|
|
|
setH( h );
|
|
|
|
setH( h );
|
|
|
@ -1622,7 +1626,18 @@ namespace NLGUI
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
void CGroupEditBox::setInputString(const ucstring &str)
|
|
|
|
void CGroupEditBox::setPrompt(const std::string &s)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_Prompt = CUtfStringView(s).toUtf32();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void CGroupEditBox::setInputString(const std::string &str)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
setInputStringAsUtf32(CUtfStringView(str).toUtf32());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGroupEditBox::setInputStringAsUtf32(const ::u32string &str)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_InputString = str;
|
|
|
|
_InputString = str;
|
|
|
|
if (_CursorPos > (sint32) str.length())
|
|
|
|
if (_CursorPos > (sint32) str.length())
|
|
|
@ -1638,18 +1653,17 @@ namespace NLGUI
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
void CGroupEditBox::setDefaultInputString(const ucstring &str)
|
|
|
|
void CGroupEditBox::setDefaultInputString(const std::string &str)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_DefaultInputString= true;
|
|
|
|
_DefaultInputString= true;
|
|
|
|
setInputString(str);
|
|
|
|
setInputString(str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
sint32 CGroupEditBox::getInputStringAsInt() const
|
|
|
|
sint32 CGroupEditBox::getInputStringAsInt() const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
sint32 value;
|
|
|
|
sint32 value;
|
|
|
|
fromString(_InputString.toString(), value);
|
|
|
|
fromString(getInputString(), value);
|
|
|
|
return value;
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1663,7 +1677,7 @@ namespace NLGUI
|
|
|
|
sint64 CGroupEditBox::getInputStringAsInt64() const
|
|
|
|
sint64 CGroupEditBox::getInputStringAsInt64() const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
sint64 value;
|
|
|
|
sint64 value;
|
|
|
|
fromString(_InputString.toString(), value);
|
|
|
|
fromString(getInputString(), value);
|
|
|
|
return value;
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1677,7 +1691,7 @@ namespace NLGUI
|
|
|
|
float CGroupEditBox::getInputStringAsFloat() const
|
|
|
|
float CGroupEditBox::getInputStringAsFloat() const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
float value;
|
|
|
|
float value;
|
|
|
|
fromString(_InputString.toString(), value);
|
|
|
|
fromString(getInputString(), value);
|
|
|
|
return value;
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1691,8 +1705,8 @@ namespace NLGUI
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
void CGroupEditBox::cutSelection()
|
|
|
|
void CGroupEditBox::cutSelection()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
sint32 minPos= min(_CursorPos, _SelectCursorPos);
|
|
|
|
ptrdiff_t minPos= min(_CursorPos, _SelectCursorPos);
|
|
|
|
sint32 maxPos= max(_CursorPos, _SelectCursorPos);
|
|
|
|
ptrdiff_t maxPos= max(_CursorPos, _SelectCursorPos);
|
|
|
|
// cut the selection
|
|
|
|
// cut the selection
|
|
|
|
if(!_InputString.empty())
|
|
|
|
if(!_InputString.empty())
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -1704,12 +1718,12 @@ namespace NLGUI
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
ucstring CGroupEditBox::getSelection()
|
|
|
|
std::string CGroupEditBox::getSelection()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
sint32 minPos= min(_CursorPos, _SelectCursorPos);
|
|
|
|
ptrdiff_t minPos= min(_CursorPos, _SelectCursorPos);
|
|
|
|
sint32 maxPos= max(_CursorPos, _SelectCursorPos);
|
|
|
|
ptrdiff_t maxPos= max(_CursorPos, _SelectCursorPos);
|
|
|
|
// get the selection
|
|
|
|
// get the selection
|
|
|
|
return _InputString.substr(minPos, maxPos-minPos);
|
|
|
|
return CUtfStringView(_InputString.substr(minPos, maxPos-minPos)).toUtf8();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1736,42 +1750,38 @@ namespace NLGUI
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
void CGroupEditBox::setInputStringAsStdString(const std::string &str)
|
|
|
|
std::string CGroupEditBox::getPrompt() const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
setInputString(ucstring(str));
|
|
|
|
return NLMISC::CUtfStringView(_Prompt).toUtf8();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
std::string CGroupEditBox::getInputStringAsStdString() const
|
|
|
|
std::string CGroupEditBox::getInputString() const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::string result;
|
|
|
|
return NLMISC::CUtfStringView(_InputString).toUtf8();
|
|
|
|
_InputString.toString(result);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
void CGroupEditBox::setInputStringAsUtf8(const std::string &str)
|
|
|
|
void CGroupEditBox::setInputStringAsUtf16(const ucstring &str)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ucstring tmp;
|
|
|
|
setInputStringAsUtf32(CUtfStringView(str).toUtf32());
|
|
|
|
tmp.fromUtf8(str);
|
|
|
|
|
|
|
|
setInputString(tmp);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
std::string CGroupEditBox::getInputStringAsUtf8() const
|
|
|
|
ucstring CGroupEditBox::getInputStringAsUtf16() const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return _InputString.toUtf8();
|
|
|
|
return CUtfStringView(_InputString).toUtf16();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
void CGroupEditBox::setCommand(const ucstring &command, bool execute)
|
|
|
|
void CGroupEditBox::setCommand(const std::string &command, bool execute)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// do nothing if frozen
|
|
|
|
// do nothing if frozen
|
|
|
|
if(_Frozen)
|
|
|
|
if(_Frozen)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
// set the string and maybe execute
|
|
|
|
// set the string and maybe execute
|
|
|
|
setInputString((ucchar) '/' + command);
|
|
|
|
setInputString('/' + command);
|
|
|
|
if (execute)
|
|
|
|
if (execute)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// stop selection
|
|
|
|
// stop selection
|
|
|
@ -1826,18 +1836,35 @@ namespace NLGUI
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
void CGroupEditBox::serialConfig(NLMISC::IStream &f)
|
|
|
|
void CGroupEditBox::serialConfig(NLMISC::IStream &f)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
f.serialVersion(0);
|
|
|
|
uint version = f.serialVersion(1);
|
|
|
|
if(_DefaultInputString) // Don't want to save the default input
|
|
|
|
if(_DefaultInputString) // Don't want to save the default input
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_DefaultInputString= false;
|
|
|
|
_DefaultInputString= false;
|
|
|
|
_InputString.clear();
|
|
|
|
_InputString.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
f.serial(_InputString);
|
|
|
|
if (version < 1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ucstring str;
|
|
|
|
|
|
|
|
if (!f.isReading())
|
|
|
|
|
|
|
|
str = CUtfStringView(_InputString).toUtf16();
|
|
|
|
|
|
|
|
f.serial(str);
|
|
|
|
|
|
|
|
if (f.isReading())
|
|
|
|
|
|
|
|
_InputString = CUtfStringView(str).toUtf32();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
std::string str;
|
|
|
|
|
|
|
|
if (!f.isReading())
|
|
|
|
|
|
|
|
str = CUtfStringView(_InputString).toUtf8();
|
|
|
|
|
|
|
|
f.serial(str);
|
|
|
|
|
|
|
|
if (f.isReading())
|
|
|
|
|
|
|
|
_InputString = CUtfStringView(str).toUtf32();
|
|
|
|
|
|
|
|
}
|
|
|
|
f.serial(_CursorPos);
|
|
|
|
f.serial(_CursorPos);
|
|
|
|
f.serial(_PrevNumLine);
|
|
|
|
f.serial(_PrevNumLine);
|
|
|
|
if (f.isReading())
|
|
|
|
if (f.isReading())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
setInputString(_InputString);
|
|
|
|
setInputStringAsUtf32(_InputString);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// serial selection
|
|
|
|
// serial selection
|
|
|
@ -1854,7 +1881,7 @@ namespace NLGUI
|
|
|
|
void CGroupEditBox::onQuit()
|
|
|
|
void CGroupEditBox::onQuit()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// clear the text and restore backup pos before final save
|
|
|
|
// clear the text and restore backup pos before final save
|
|
|
|
setInputString(ucstring(""));
|
|
|
|
setInputStringAsUtf32(::u32string());
|
|
|
|
_CurrSelection = NULL;
|
|
|
|
_CurrSelection = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1862,7 +1889,7 @@ namespace NLGUI
|
|
|
|
void CGroupEditBox::onLoadConfig()
|
|
|
|
void CGroupEditBox::onLoadConfig()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// config is not saved when there's an empty string, so restore that default state.
|
|
|
|
// config is not saved when there's an empty string, so restore that default state.
|
|
|
|
setInputString(ucstring(""));
|
|
|
|
setInputStringAsUtf32(::u32string());
|
|
|
|
_CurrSelection = NULL;
|
|
|
|
_CurrSelection = NULL;
|
|
|
|
_PrevNumLine = 1;
|
|
|
|
_PrevNumLine = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1877,7 +1904,7 @@ namespace NLGUI
|
|
|
|
if (_DefaultInputString)
|
|
|
|
if (_DefaultInputString)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_DefaultInputString= false;
|
|
|
|
_DefaultInputString= false;
|
|
|
|
setInputString(ucstring());
|
|
|
|
setInputStringAsUtf32(::u32string());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_CanRedo = false;
|
|
|
|
_CanRedo = false;
|
|
|
|
_CanUndo = false;
|
|
|
|
_CanUndo = false;
|
|
|
|