summaryrefslogtreecommitdiff
path: root/indra/newview/llchatmsgbox.cpp
diff options
context:
space:
mode:
authorJames Cook <james@lindenlab.com>2009-10-03 23:40:28 +0000
committerJames Cook <james@lindenlab.com>2009-10-03 23:40:28 +0000
commitada0f4fa221f2c7070fb02a2b7ff903bdde11c45 (patch)
tree0ede83511c304110138c01d16da2fff55162ef31 /indra/newview/llchatmsgbox.cpp
parentb1a280841e1823a19658923a8eefeb67d1d70735 (diff)
Merge inspectors UI project, gooey-4, into viewer-2 trunk. Added new tooltips to 3D avatars, 2D avatar names, and 3D objects. Refactors tooltips and text boxes, line editors, and text editors. Breaks LLExpandableTextBox, but a fix is coming.
Resolved conflicts in lltexteditor.cpp, llchatitemscontainerctrl.cpp, llchatmsgbox.cpp, llfloaterbuycurrency.cpp, llnearbychat.cpp, floater_buy_currency.xml, and ru/strings.xml Merging revisions 134925-135157 of svn+ssh://svn.lindenlab.com/svn/linden/branches/gooey/gooey-4 into C:\source\viewer-2.0.0-3, respecting ancestry
Diffstat (limited to 'indra/newview/llchatmsgbox.cpp')
-rw-r--r--indra/newview/llchatmsgbox.cpp110
1 files changed, 41 insertions, 69 deletions
diff --git a/indra/newview/llchatmsgbox.cpp b/indra/newview/llchatmsgbox.cpp
index bd0c36b44a..6eaafc9059 100644
--- a/indra/newview/llchatmsgbox.cpp
+++ b/indra/newview/llchatmsgbox.cpp
@@ -39,88 +39,60 @@
static LLDefaultChildRegistry::Register<LLChatMsgBox> r("text_chat");
-LLChatMsgBox::Params::Params() :
- block_spacing("block_spacing", 10)
+class ChatSeparator : public LLTextSegment
{
- line_spacing = 4;
-}
+public:
+ ChatSeparator(S32 start, S32 end)
+ : LLTextSegment(start, end),
+ mEditor(NULL)
+ {}
-LLChatMsgBox::LLChatMsgBox(const Params& p) :
- LLTextBox(p),
- mBlockSpacing(p.block_spacing)
-{}
+ /*virtual*/ void linkToDocument(class LLTextBase* editor)
+ {
+ mEditor = editor;
+ }
-void LLChatMsgBox::addText( const LLStringExplicit& text )
-{
- LLWString t = mText.getWString();
- if (! t.empty())
+ /*virtual*/ void unlinkFromDocument(class LLTextBase* editor)
{
- t += '\n';
+ mEditor = NULL;
}
- t += getWrappedText(text);
- LLTextBox::setText(wstring_to_utf8str(t));
- mSeparatorOffset.push_back(getLength());
-}
-void LLChatMsgBox::setText(const LLStringExplicit& text)
-{
- mSeparatorOffset.clear();
- mText.clear();
- addText(text);
-}
+ /*virtual*/ S32 getWidth(S32 first_char, S32 num_chars) const
+ {
+ return mEditor->getDocumentPanel()->getRect().getWidth();
+ }
-void LLChatMsgBox::setValue(const LLSD& value )
-{
- setText(value.asString());
-}
+ /*virtual*/ F32 draw(S32 start, S32 end, S32 selection_start, S32 selection_end, const LLRect& draw_rect)
+ {
+ gl_line_2d(draw_rect.mLeft + 5, draw_rect.getCenterY(), draw_rect.mRight - 5, draw_rect.getCenterY(), LLColor4::grey);
+ return draw_rect.getWidth();
+ }
+
+private:
+ LLTextBase* mEditor;
+};
-S32 LLChatMsgBox::getTextPixelHeight()
-{
- S32 num_blocks = mSeparatorOffset.size();
- S32 num_lines = getTextLinesNum();
- return (S32)(num_lines * mDefaultFont->getLineHeight() + \
- (num_lines-1) * mLineSpacing + \
- (num_blocks-1) * mBlockSpacing + \
- 2 * mLineSpacing);
-}
-S32 LLChatMsgBox::getTextLinesNum()
+LLChatMsgBox::Params::Params() :
+ block_spacing("block_spacing", 10)
{
- S32 num_lines = getLineCount();
- if (num_lines < 1)
- {
- num_lines = 1;
- }
-
- return num_lines;
+ line_spacing.pixels = 4;
}
-void LLChatMsgBox::drawText(S32 x, S32 y, const LLWString &text, const LLColor4 &color)
-{
- S32 start = 0;
- S32 width = getRect().getWidth()-10;
+LLChatMsgBox::LLChatMsgBox(const Params& p) :
+ LLTextBox(p),
+ mBlockSpacing(p.block_spacing)
+{}
- // iterate through each block of text that has been added
- y -= mLineSpacing;
- for (std::vector<S32>::iterator it = mSeparatorOffset.begin(); it != mSeparatorOffset.end() ;)
+void LLChatMsgBox::addText( const LLStringExplicit& text )
+{
+ S32 length = getLength();
+ // if there is existing text, add a separator
+ if (length > 0)
{
- // display the text for this block
- S32 num_chars = *it - start;
- LLWString text = mDisplayText.substr(start, num_chars);
- LLTextBox::drawText(x, y, text, color);
-
- // exit the loop if this is the last text block
- start += num_chars + 1; // skip the newline
- if (++it == mSeparatorOffset.end())
- {
- break;
- }
-
- // output a separator line between blocks
- S32 num_lines = std::count(text.begin(), text.end(), '\n') + 1;
- y -= num_lines * (llfloor(mDefaultFont->getLineHeight()) + mLineSpacing);
- S32 sep_y = y - mBlockSpacing/2 + mLineSpacing/2;
- gl_line_2d(5, sep_y, width, sep_y, LLColor4::grey);
- y -= mBlockSpacing;
+ // chat separator exists right before the null terminator
+ insertSegment(new ChatSeparator(length - 1, length - 1));
}
+ // prepend newline only if there is some existing text
+ appendText(text, length > 0);
}