|
|
|
@ -84,7 +84,8 @@ namespace NLGUI
|
|
|
|
|
|
|
|
|
|
/// Set
|
|
|
|
|
|
|
|
|
|
void setText (const ucstring &text);
|
|
|
|
|
void setText(const std::string &text);
|
|
|
|
|
void setTextAsUtf16 (const ucstring &text);
|
|
|
|
|
void setFontName (const std::string &name);
|
|
|
|
|
void setFontSize (sint nFontSize, bool coef = true);
|
|
|
|
|
void setEmbolden (bool nEmbolden);
|
|
|
|
@ -95,7 +96,8 @@ namespace NLGUI
|
|
|
|
|
void setShadowColor (const NLMISC::CRGBA &color);
|
|
|
|
|
void setShadowOffset (sint x, sint y);
|
|
|
|
|
void setLineMaxW (sint nMaxW, bool invalidate=true);
|
|
|
|
|
void setOverflowText(const ucstring &text) { _OverflowText = text; }
|
|
|
|
|
void setOverflowText(const std::string &text) { _OverflowText = text; }
|
|
|
|
|
void setOverflowTextAsUtf16(const ucstring &text) { _OverflowText = text.toUtf8(); }
|
|
|
|
|
void setMultiLine (bool bMultiLine);
|
|
|
|
|
void setMultiLineSpace (sint nMultiLineSpace);
|
|
|
|
|
void setMultiLineMaxWOnly (bool state);
|
|
|
|
@ -112,8 +114,9 @@ namespace NLGUI
|
|
|
|
|
void disableStringSelection();
|
|
|
|
|
|
|
|
|
|
/// Get
|
|
|
|
|
|
|
|
|
|
ucstring getText() const { return _Text; }
|
|
|
|
|
std::string getText() const { return _Text; }
|
|
|
|
|
ucstring getTextAsUtf16() const;
|
|
|
|
|
ucstring getHardTextAsUtf16() const;
|
|
|
|
|
sint getFontSize() const;
|
|
|
|
|
std::string getFontName() const { return _FontName; }
|
|
|
|
|
bool getEmbolden() { return _Embolden; }
|
|
|
|
@ -124,7 +127,7 @@ namespace NLGUI
|
|
|
|
|
NLMISC::CRGBA getShadowColor() { return _ShadowColor; }
|
|
|
|
|
void getShadowOffset(sint &x, sint &y) { x = _ShadowX; y = _ShadowY; }
|
|
|
|
|
sint getLineMaxW() const { return _LineMaxW; }
|
|
|
|
|
ucstring getOverflowText() const { return _OverflowText; }
|
|
|
|
|
ucstring getOverflowTextAsUtf16() const { return _OverflowText; }
|
|
|
|
|
bool getMultiLine() const { return _MultiLine; }
|
|
|
|
|
sint getMultiLineSpace() const { return _MultiLineSpace; }
|
|
|
|
|
bool getMultiLineMaxWOnly() const { return _MultiLineMaxWOnly; }
|
|
|
|
@ -174,8 +177,9 @@ namespace NLGUI
|
|
|
|
|
/// From a line number, get the character at which it ends (not including any '\n' ), or -1 if invalid
|
|
|
|
|
void getLineEndIndex(uint line, sint &index, bool &endOfPreviousLine) const;
|
|
|
|
|
|
|
|
|
|
std::string getHardText() const { std::string result; _Text.toString (result); return result; }
|
|
|
|
|
std::string getHardText() const { return _HardText.empty() ? _Text : _HardText; }
|
|
|
|
|
void setHardText (const std::string &ht);
|
|
|
|
|
void setHardTextAsUtf16(const ucstring &ht);
|
|
|
|
|
|
|
|
|
|
std::string getColorAsString() const;
|
|
|
|
|
void setColorAsString(const std::string &ht);
|
|
|
|
@ -188,9 +192,11 @@ namespace NLGUI
|
|
|
|
|
|
|
|
|
|
/** Setup a Text with Format Tags. Text is store without color/format tags, and special array is allocated for Format association
|
|
|
|
|
*/
|
|
|
|
|
void setTextFormatTaged(const ucstring &text);
|
|
|
|
|
void setTextFormatTaged(const std::string &text);
|
|
|
|
|
void setTextFormatTagedAsUtf16(const ucstring &text);
|
|
|
|
|
|
|
|
|
|
void setSingleLineTextFormatTaged(const ucstring &text);
|
|
|
|
|
void setSingleLineTextFormatTaged(const std::string &text);
|
|
|
|
|
void setSingleLineTextFormatTagedAsUtf16(const ucstring &text);
|
|
|
|
|
|
|
|
|
|
// Remove end space
|
|
|
|
|
void removeEndSpaces();
|
|
|
|
@ -216,10 +222,12 @@ namespace NLGUI
|
|
|
|
|
int luaSetLineMaxW(CLuaState &ls);
|
|
|
|
|
|
|
|
|
|
REFLECT_EXPORT_START(CViewText, CViewBase)
|
|
|
|
|
REFLECT_STRING("text", getText, setText);
|
|
|
|
|
REFLECT_STRING("hardtext", getHardText, setHardText);
|
|
|
|
|
REFLECT_UCSTRING("uc_hardtext", getText, setText);
|
|
|
|
|
REFLECT_UCSTRING("uc_hardtext_format", getText, setTextFormatTaged);
|
|
|
|
|
REFLECT_UCSTRING("uc_hardtext_single_line_format", getText, setSingleLineTextFormatTaged);
|
|
|
|
|
// REFLECT_UCSTRING("uc_text", getTextAsUtf16, setTextAsUtf16); // Deprecate uc_ functions
|
|
|
|
|
REFLECT_UCSTRING("uc_hardtext", getHardTextAsUtf16, setHardTextAsUtf16);
|
|
|
|
|
REFLECT_UCSTRING("uc_hardtext_format", getTextAsUtf16, setTextFormatTagedAsUtf16); // FIXME: Name doesn't make sense
|
|
|
|
|
REFLECT_UCSTRING("uc_hardtext_single_line_format", getTextAsUtf16, setSingleLineTextFormatTagedAsUtf16); // FIXME: Name doesn't make sense
|
|
|
|
|
REFLECT_STRING ("color", getColorAsString, setColorAsString);
|
|
|
|
|
REFLECT_RGBA ("color_rgba", getColorRGBA, setColorRGBA);
|
|
|
|
|
REFLECT_SINT32 ("alpha", getAlpha, setAlpha);
|
|
|
|
@ -228,7 +236,6 @@ namespace NLGUI
|
|
|
|
|
REFLECT_LUA_METHOD("setLineMaxW", luaSetLineMaxW);
|
|
|
|
|
REFLECT_EXPORT_END
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
virtual void serial(NLMISC::IStream &f);
|
|
|
|
|
|
|
|
|
|
// Sets the parent element
|
|
|
|
@ -236,9 +243,11 @@ namespace NLGUI
|
|
|
|
|
void setParentElm( CInterfaceElement *parent ){ _ParentElm = parent; }
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
std::string _HardtextFormat;
|
|
|
|
|
/// Text to display.
|
|
|
|
|
ucstring _Text;
|
|
|
|
|
std::string _HardTextFormat;
|
|
|
|
|
std::string _HardText;
|
|
|
|
|
std::string _Text;
|
|
|
|
|
mutable sint _TextLength;
|
|
|
|
|
/// index of the computed String associated to this text control
|
|
|
|
|
uint _Index;
|
|
|
|
|
/// info on the computed String associated to this text control
|
|
|
|
@ -278,7 +287,7 @@ namespace NLGUI
|
|
|
|
|
sint32 _LineMaxW;
|
|
|
|
|
/// For single line, true if the text is clamped (ie displayed with "...")
|
|
|
|
|
bool _SingleLineTextClamped;
|
|
|
|
|
ucstring _OverflowText;
|
|
|
|
|
std::string _OverflowText;
|
|
|
|
|
|
|
|
|
|
/// Multiple lines handling
|
|
|
|
|
bool _MultiLine;
|
|
|
|
@ -339,7 +348,7 @@ namespace NLGUI
|
|
|
|
|
public:
|
|
|
|
|
// default ctor
|
|
|
|
|
CWord(uint numSpaces = 0) : Index(0), NumSpaces(numSpaces) {}
|
|
|
|
|
ucstring Text;
|
|
|
|
|
std::string Text;
|
|
|
|
|
uint Index; // index of the info for this word
|
|
|
|
|
NL3D::UTextContext::CStringInfo Info;
|
|
|
|
|
uint NumSpaces; // number of spaces before this word
|
|
|
|
@ -347,7 +356,7 @@ namespace NLGUI
|
|
|
|
|
CFormatInfo Format;
|
|
|
|
|
public:
|
|
|
|
|
// build from a string, using the current text context
|
|
|
|
|
void build(const ucstring &text, NL3D::UTextContext &textContext, uint numSpaces= 0);
|
|
|
|
|
void build(const std::string &text, NL3D::UTextContext &textContext, uint numSpaces= 0);
|
|
|
|
|
};
|
|
|
|
|
typedef std::vector<CWord> TWordVect;
|
|
|
|
|
|
|
|
|
@ -360,7 +369,7 @@ namespace NLGUI
|
|
|
|
|
// Clear the line & remove text contexts
|
|
|
|
|
void clear(NL3D::UTextContext &textContext);
|
|
|
|
|
// Add a new word (and its context) in the line + a number of spaces to append at the end of the line
|
|
|
|
|
void addWord(const ucstring &word, uint numSpaces, const CFormatInfo &wordFormat, float fontWidth, NL3D::UTextContext &textContext);
|
|
|
|
|
void addWord(const std::string &word, uint numSpaces, const CFormatInfo &wordFormat, float fontWidth, NL3D::UTextContext &textContext);
|
|
|
|
|
void addWord(const CWord &word, float fontWidth);
|
|
|
|
|
uint getNumWords() const { return (uint)_Words.size(); }
|
|
|
|
|
CWord &getWord(uint index) { return _Words[index]; }
|
|
|
|
@ -434,7 +443,7 @@ namespace NLGUI
|
|
|
|
|
void setup ();
|
|
|
|
|
void setupDefault ();
|
|
|
|
|
|
|
|
|
|
void setStringSelectionSkipingSpace(uint stringId, const ucstring &text, sint charStart, sint charEnd);
|
|
|
|
|
void setStringSelectionSkipingSpace(uint stringId, const std::string &text, sint charStart, sint charEnd);
|
|
|
|
|
|
|
|
|
|
// void pushString(const ucstring &str, bool deleteSpaceAtStart = false);
|
|
|
|
|
|
|
|
|
@ -442,7 +451,7 @@ namespace NLGUI
|
|
|
|
|
void onInvalidateContent();
|
|
|
|
|
|
|
|
|
|
// may append a new line, and append a word to the last line (no spaces)
|
|
|
|
|
void flushWordInLine(ucstring &ucCurrentWord, bool &linePushed, const CFormatInfo &wordFormat);
|
|
|
|
|
void flushWordInLine(std::string &ucCurrentWord, bool &linePushed, const CFormatInfo &wordFormat);
|
|
|
|
|
// Clear all the lines and free their datas
|
|
|
|
|
void clearLines();
|
|
|
|
|
// Update in the case of a multiline text
|
|
|
|
@ -456,7 +465,7 @@ namespace NLGUI
|
|
|
|
|
void addDontClipWordLine(std::vector<CWord> &currLine);
|
|
|
|
|
|
|
|
|
|
// FormatTag build.
|
|
|
|
|
static void buildFormatTagText(const ucstring &text, ucstring &textBuild, std::vector<CFormatTag> &formatTags, std::vector<ucstring> &tooltips);
|
|
|
|
|
static void buildFormatTagText(const std::string &text, std::string &textBuild, std::vector<CFormatTag> &formatTags, std::vector<ucstring> &tooltips);
|
|
|
|
|
// FormatTag parsing.
|
|
|
|
|
bool isFormatTagChange(uint textIndex, uint ctIndex) const;
|
|
|
|
|
void getFormatTagChange(uint textIndex, uint &ctIndex, CFormatInfo &wordFormat) const;
|
|
|
|
|