summaryrefslogtreecommitdiff
path: root/indra/llui/lltextbase.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llui/lltextbase.cpp')
-rw-r--r--indra/llui/lltextbase.cpp290
1 files changed, 147 insertions, 143 deletions
diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp
index c1eedf93a7..0aebf7543c 100644
--- a/indra/llui/lltextbase.cpp
+++ b/indra/llui/lltextbase.cpp
@@ -207,7 +207,7 @@ LLTextBase::LLTextBase(const LLTextBase::Params &p)
mSelectedBGColor(p.bg_selected_color),
mReflowIndex(S32_MAX),
mCursorPos( 0 ),
- mScrollNeeded(FALSE),
+ mScrollNeeded(false),
mDesiredXPixel(-1),
mHPad(p.h_pad),
mVPad(p.v_pad),
@@ -224,7 +224,7 @@ LLTextBase::LLTextBase(const LLTextBase::Params &p)
mScrollIndex(-1),
mSelectionStart( 0 ),
mSelectionEnd( 0 ),
- mIsSelecting( FALSE ),
+ mIsSelecting( false ),
mPlainText ( p.plain_text ),
mWordWrap(p.wrap),
mUseEllipses( p.use_ellipses ),
@@ -309,7 +309,7 @@ void LLTextBase::initFromParams(const LLTextBase::Params& p)
bool LLTextBase::truncate()
{
- BOOL did_truncate = FALSE;
+ bool did_truncate = false;
// First rough check - if we're less than 1/4th the size, we're OK
if (getLength() >= S32(mMaxTextByteLength / 4))
@@ -320,12 +320,12 @@ bool LLTextBase::truncate()
if (value.type() == LLSD::TypeString)
{
// save a copy for strings.
- utf8_byte_size = value.size();
+ utf8_byte_size = static_cast<S32>(value.size());
}
else
{
// non string LLSDs need explicit conversion to string
- utf8_byte_size = value.asString().size();
+ utf8_byte_size = static_cast<S32>(value.asString().size());
}
if ( utf8_byte_size > mMaxTextByteLength )
@@ -335,8 +335,8 @@ bool LLTextBase::truncate()
temp_utf8_text = utf8str_truncate( temp_utf8_text, mMaxTextByteLength );
LLWString text = utf8str_to_wstring( temp_utf8_text );
// remove extra bit of current string, to preserve formatting, etc.
- removeStringNoUndo(text.size(), getWText().size() - text.size());
- did_truncate = TRUE;
+ removeStringNoUndo(static_cast<S32>(text.size()), static_cast<S32>(getWText().size() - text.size()));
+ did_truncate = true;
}
}
@@ -401,8 +401,8 @@ std::vector<LLRect> LLTextBase::getSelectionRects()
// Use F32 otherwise a string of multiple segments
// will accumulate a large error
- F32 left_precise = line_iter->mRect.mLeft;
- F32 right_precise = line_iter->mRect.mLeft;
+ F32 left_precise = (F32)line_iter->mRect.mLeft;
+ F32 right_precise = (F32)line_iter->mRect.mLeft;
for (; segment_iter != mSegments.end(); ++segment_iter, segment_offset = 0)
{
@@ -448,8 +448,8 @@ std::vector<LLRect> LLTextBase::getSelectionRects()
}
LLRect selection_rect;
- selection_rect.mLeft = left_precise;
- selection_rect.mRight = right_precise;
+ selection_rect.mLeft = (S32)left_precise;
+ selection_rect.mRight = (S32)right_precise;
selection_rect.mBottom = line_iter->mRect.mBottom;
selection_rect.mTop = line_iter->mRect.mTop;
@@ -584,9 +584,8 @@ void LLTextBase::drawCursor()
if (LL_KIM_OVERWRITE == gKeyboard->getInsertMode() && !hasSelection() && text[mCursorPos] != '\n')
{
- LLColor4 text_color;
const LLFontGL* fontp;
- text_color = segmentp->getColor();
+ const LLColor4& text_color = segmentp->getColor();
fontp = segmentp->getStyle()->getFont();
fontp->render(text, mCursorPos, cursor_rect,
LLColor4(1.f - text_color.mV[VRED], 1.f - text_color.mV[VGREEN], 1.f - text_color.mV[VBLUE], alpha),
@@ -598,7 +597,7 @@ void LLTextBase::drawCursor()
// Make sure the IME is in the right place
LLRect screen_pos = calcScreenRect();
- LLCoordGL ime_pos( screen_pos.mLeft + llfloor(cursor_rect.mLeft), screen_pos.mBottom + llfloor(cursor_rect.mTop) );
+ LLCoordGL ime_pos( screen_pos.mLeft + cursor_rect.mLeft, screen_pos.mBottom + cursor_rect.mTop );
ime_pos.mX = (S32) (ime_pos.mX * LLUI::getScaleFactor().mV[VX]);
ime_pos.mY = (S32) (ime_pos.mY * LLUI::getScaleFactor().mV[VY]);
@@ -617,7 +616,7 @@ void LLTextBase::drawText()
}
else if (useLabel())
{
- text_len = mLabel.getWString().length();
+ text_len = static_cast<S32>(mLabel.getWString().length());
}
S32 selection_left = -1;
@@ -686,7 +685,7 @@ void LLTextBase::drawText()
// Find the start of the first word
U32 word_start = seg_start, word_end = -1;
- U32 text_length = wstrText.length();
+ U32 text_length = static_cast<U32>(wstrText.length());
while ( (word_start < text_length) && (!LLStringOps::isAlpha(wstrText[word_start])) )
{
word_start++;
@@ -755,9 +754,9 @@ void LLTextBase::drawText()
line_end = next_start;
}
- LLRectf text_rect(line.mRect.mLeft, line.mRect.mTop, line.mRect.mRight, line.mRect.mBottom);
- text_rect.mRight = mDocumentView->getRect().getWidth(); // clamp right edge to document extents
- text_rect.translate(mDocumentView->getRect().mLeft, mDocumentView->getRect().mBottom); // adjust by scroll position
+ LLRectf text_rect((F32)line.mRect.mLeft, (F32)line.mRect.mTop, (F32)line.mRect.mRight, (F32)line.mRect.mBottom);
+ text_rect.mRight = (F32)mDocumentView->getRect().getWidth(); // clamp right edge to document extents
+ text_rect.translate((F32)mDocumentView->getRect().mLeft, (F32)mDocumentView->getRect().mBottom); // adjust by scroll position
// draw a single line of text
S32 seg_start = line_start;
@@ -789,7 +788,7 @@ void LLTextBase::drawText()
}
// Draw squiggly lines under any visible misspelled words
- while ( (mMisspellRanges.end() != misspell_it) && (misspell_it->first < seg_end) && (misspell_it->second > seg_start) )
+ while ( (mMisspellRanges.end() != misspell_it) && (misspell_it->first < (U32)seg_end) && (misspell_it->second > (U32)seg_start) )
{
// Skip the current word if the user is still busy editing it
if ( (!mSpellCheckTimer.hasExpired()) && (misspell_it->first <= (U32)mCursorPos) && (misspell_it->second >= (U32)mCursorPos) )
@@ -798,17 +797,17 @@ void LLTextBase::drawText()
continue;
}
- U32 misspell_start = llmax<U32>(misspell_it->first, seg_start), misspell_end = llmin<U32>(misspell_it->second, seg_end);
+ U32 misspell_start = llmax<U32>(misspell_it->first, (U32)seg_start), misspell_end = llmin<U32>(misspell_it->second, (U32)seg_end);
S32 squiggle_start = 0, squiggle_end = 0, pony = 0;
cur_segment->getDimensions(seg_start - cur_segment->getStart(), misspell_start - seg_start, squiggle_start, pony);
cur_segment->getDimensions(misspell_start - cur_segment->getStart(), misspell_end - misspell_start, squiggle_end, pony);
- squiggle_start += text_rect.mLeft;
+ squiggle_start += (S32)text_rect.mLeft;
pony = (squiggle_end + 3) / 6;
squiggle_start += squiggle_end / 2 - pony * 3;
squiggle_end = squiggle_start + pony * 6;
- S32 squiggle_bottom = text_rect.mBottom + (S32)cur_segment->getStyle()->getFont()->getDescenderHeight();
+ S32 squiggle_bottom = (S32)text_rect.mBottom + (S32)cur_segment->getStyle()->getFont()->getDescenderHeight();
gGL.color4ub(255, 0, 0, 200);
while (squiggle_start + 1 < squiggle_end)
@@ -821,7 +820,7 @@ void LLTextBase::drawText()
squiggle_start += 4;
}
- if (misspell_it->second > seg_end)
+ if (misspell_it->second > (U32)seg_end)
{
break;
}
@@ -845,9 +844,16 @@ S32 LLTextBase::insertStringNoUndo(S32 pos, const LLWString &wstr, LLTextBase::s
beforeValueChange();
S32 old_len = getLength(); // length() returns character length
- S32 insert_len = wstr.length();
+ S32 insert_len = static_cast<S32>(wstr.length());
pos = getEditableIndex(pos, true);
+ if (pos > old_len)
+ {
+ pos = old_len;
+ // Should not happen,
+ // if you encounter this, check where wrong position comes from
+ llassert(false);
+ }
segment_set_t::iterator seg_iter = getEditableSegIterContaining(pos);
@@ -909,7 +915,7 @@ S32 LLTextBase::insertStringNoUndo(S32 pos, const LLWString &wstr, LLTextBase::s
{
LLStyleSP emoji_style;
LLEmojiDictionary* ed = LLEmojiDictionary::instanceExists() ? LLEmojiDictionary::getInstance() : NULL;
- for (S32 text_kitty = 0, text_len = wstr.size(); text_kitty < text_len; text_kitty++)
+ for (S32 text_kitty = 0, text_len = static_cast<S32>(wstr.size()); text_kitty < text_len; text_kitty++)
{
llwchar code = wstr[text_kitty];
bool isEmoji = ed ? ed->isEmoji(code) : LLStringOps::isEmoji(code);
@@ -1111,14 +1117,14 @@ void LLTextBase::insertSegment(LLTextSegmentPtr segment_to_insert)
}
//virtual
-BOOL LLTextBase::handleMouseDown(S32 x, S32 y, MASK mask)
+bool LLTextBase::handleMouseDown(S32 x, S32 y, MASK mask)
{
// handle triple click
if (!mTripleClickTimer.hasExpired())
{
if (mSkipTripleClick)
{
- return TRUE;
+ return true;
}
S32 real_line = getLineNumFromDocIndex(mCursorPos, false);
@@ -1146,27 +1152,27 @@ BOOL LLTextBase::handleMouseDown(S32 x, S32 y, MASK mask)
if (line_start == -1)
{
- return TRUE;
+ return true;
}
mSelectionEnd = line_start;
mSelectionStart = line_end;
setCursorPos(line_start);
- return TRUE;
+ return true;
}
LLTextSegmentPtr cur_segment = getSegmentAtLocalPos(x, y);
if (cur_segment && cur_segment->handleMouseDown(x, y, mask))
{
- return TRUE;
+ return true;
}
return LLUICtrl::handleMouseDown(x, y, mask);
}
//virtual
-BOOL LLTextBase::handleMouseUp(S32 x, S32 y, MASK mask)
+bool LLTextBase::handleMouseUp(S32 x, S32 y, MASK mask)
{
LLTextSegmentPtr cur_segment = getSegmentAtLocalPos(x, y);
if (hasMouseCapture() && cur_segment && cur_segment->handleMouseUp(x, y, mask))
@@ -1179,62 +1185,62 @@ BOOL LLTextBase::handleMouseUp(S32 x, S32 y, MASK mask)
// *TODO: send URL here?
(*mURLClickSignal)(this, LLSD() );
}
- return TRUE;
+ return true;
}
return LLUICtrl::handleMouseUp(x, y, mask);
}
//virtual
-BOOL LLTextBase::handleMiddleMouseDown(S32 x, S32 y, MASK mask)
+bool LLTextBase::handleMiddleMouseDown(S32 x, S32 y, MASK mask)
{
LLTextSegmentPtr cur_segment = getSegmentAtLocalPos(x, y);
if (cur_segment && cur_segment->handleMiddleMouseDown(x, y, mask))
{
- return TRUE;
+ return true;
}
return LLUICtrl::handleMiddleMouseDown(x, y, mask);
}
//virtual
-BOOL LLTextBase::handleMiddleMouseUp(S32 x, S32 y, MASK mask)
+bool LLTextBase::handleMiddleMouseUp(S32 x, S32 y, MASK mask)
{
LLTextSegmentPtr cur_segment = getSegmentAtLocalPos(x, y);
if (cur_segment && cur_segment->handleMiddleMouseUp(x, y, mask))
{
- return TRUE;
+ return true;
}
return LLUICtrl::handleMiddleMouseUp(x, y, mask);
}
//virtual
-BOOL LLTextBase::handleRightMouseDown(S32 x, S32 y, MASK mask)
+bool LLTextBase::handleRightMouseDown(S32 x, S32 y, MASK mask)
{
LLTextSegmentPtr cur_segment = getSegmentAtLocalPos(x, y);
if (cur_segment && cur_segment->handleRightMouseDown(x, y, mask))
{
- return TRUE;
+ return true;
}
return LLUICtrl::handleRightMouseDown(x, y, mask);
}
//virtual
-BOOL LLTextBase::handleRightMouseUp(S32 x, S32 y, MASK mask)
+bool LLTextBase::handleRightMouseUp(S32 x, S32 y, MASK mask)
{
LLTextSegmentPtr cur_segment = getSegmentAtLocalPos(x, y);
if (cur_segment && cur_segment->handleRightMouseUp(x, y, mask))
{
- return TRUE;
+ return true;
}
return LLUICtrl::handleRightMouseUp(x, y, mask);
}
//virtual
-BOOL LLTextBase::handleDoubleClick(S32 x, S32 y, MASK mask)
+bool LLTextBase::handleDoubleClick(S32 x, S32 y, MASK mask)
{
//Don't start triple click timer if user have clicked on scrollbar
mVisibleTextRect = mScroller ? mScroller->getContentWindowRect() : getLocalRect();
@@ -1247,50 +1253,50 @@ BOOL LLTextBase::handleDoubleClick(S32 x, S32 y, MASK mask)
LLTextSegmentPtr cur_segment = getSegmentAtLocalPos(x, y);
if (cur_segment && cur_segment->handleDoubleClick(x, y, mask))
{
- return TRUE;
+ return true;
}
return LLUICtrl::handleDoubleClick(x, y, mask);
}
//virtual
-BOOL LLTextBase::handleHover(S32 x, S32 y, MASK mask)
+bool LLTextBase::handleHover(S32 x, S32 y, MASK mask)
{
LLTextSegmentPtr cur_segment = getSegmentAtLocalPos(x, y);
if (cur_segment && cur_segment->handleHover(x, y, mask))
{
- return TRUE;
+ return true;
}
return LLUICtrl::handleHover(x, y, mask);
}
//virtual
-BOOL LLTextBase::handleScrollWheel(S32 x, S32 y, S32 clicks)
+bool LLTextBase::handleScrollWheel(S32 x, S32 y, S32 clicks)
{
LLTextSegmentPtr cur_segment = getSegmentAtLocalPos(x, y);
if (cur_segment && cur_segment->handleScrollWheel(x, y, clicks))
{
- return TRUE;
+ return true;
}
return LLUICtrl::handleScrollWheel(x, y, clicks);
}
//virtual
-BOOL LLTextBase::handleToolTip(S32 x, S32 y, MASK mask)
+bool LLTextBase::handleToolTip(S32 x, S32 y, MASK mask)
{
LLTextSegmentPtr cur_segment = getSegmentAtLocalPos(x, y);
if (cur_segment && cur_segment->handleToolTip(x, y, mask))
{
- return TRUE;
+ return true;
}
return LLUICtrl::handleToolTip(x, y, mask);
}
//virtual
-void LLTextBase::reshape(S32 width, S32 height, BOOL called_from_parent)
+void LLTextBase::reshape(S32 width, S32 height, bool called_from_parent)
{
if (width != getRect().getWidth() || height != getRect().getHeight() || LLView::sForceReshape)
{
@@ -1361,23 +1367,23 @@ void LLTextBase::draw()
{
bg_rect.intersectWith(text_rect);
}
- LLColor4 bg_color = mReadOnly
+ const LLColor4& bg_color = mReadOnly
? mReadOnlyBgColor.get()
: hasFocus()
? mFocusBgColor.get()
: mWriteableBgColor.get();
- gl_rect_2d(text_rect, bg_color % alpha, TRUE);
+ gl_rect_2d(text_rect, bg_color % alpha, true);
}
// Draw highlighted if needed
if( ll::ui::SearchableControl::getHighlighted() )
{
- LLColor4 bg_color = ll::ui::SearchableControl::getHighlightColor();
+ const LLColor4& bg_color = ll::ui::SearchableControl::getHighlightColor();
LLRect bg_rect = mVisibleTextRect;
if( mScroller )
bg_rect.intersectWith( text_rect );
- gl_rect_2d( text_rect, bg_color, TRUE );
+ gl_rect_2d( text_rect, bg_color, true );
}
bool should_clip = mClip || mScroller != NULL;
@@ -1398,28 +1404,28 @@ void LLTextBase::draw()
drawCursor();
}
- mDocumentView->setVisibleDirect(FALSE);
+ mDocumentView->setVisibleDirect(false);
LLUICtrl::draw();
- mDocumentView->setVisibleDirect(TRUE);
+ mDocumentView->setVisibleDirect(true);
}
//virtual
-void LLTextBase::setColor( const LLColor4& c )
+void LLTextBase::setColor( const LLUIColor& c )
{
mFgColor = c;
mStyleDirty = true;
}
//virtual
-void LLTextBase::setReadOnlyColor(const LLColor4 &c)
+void LLTextBase::setReadOnlyColor(const LLUIColor &c)
{
mReadOnlyFgColor = c;
mStyleDirty = true;
}
//virtual
-void LLTextBase::onVisibilityChange( BOOL new_visibility )
+void LLTextBase::onVisibilityChange( bool new_visibility )
{
LLContextMenu* menu = static_cast<LLContextMenu*>(mPopupMenuHandle.get());
if(!new_visibility && menu)
@@ -1436,7 +1442,7 @@ void LLTextBase::setValue(const LLSD& value )
}
//virtual
-BOOL LLTextBase::canDeselect() const
+bool LLTextBase::canDeselect() const
{
return hasSelection();
}
@@ -1447,7 +1453,7 @@ void LLTextBase::deselect()
{
mSelectionStart = 0;
mSelectionEnd = 0;
- mIsSelecting = FALSE;
+ mIsSelecting = false;
}
bool LLTextBase::getSpellCheck() const
@@ -1462,7 +1468,7 @@ const std::string& LLTextBase::getSuggestion(U32 index) const
U32 LLTextBase::getSuggestionCount() const
{
- return mSuggestionList.size();
+ return static_cast<U32>(mSuggestionList.size());
}
void LLTextBase::replaceWithSuggestion(U32 index)
@@ -1575,7 +1581,7 @@ void LLTextBase::updateScrollFromCursor()
{
return;
}
- mScrollNeeded = FALSE;
+ mScrollNeeded = false;
// scroll so that the cursor is at the top of the page
LLRect scroller_doc_window = getVisibleDocumentRect();
@@ -1667,7 +1673,7 @@ void LLTextBase::reflow()
segment_set_t::iterator seg_iter = mSegments.begin();
S32 seg_offset = 0;
S32 line_start_index = 0;
- const F32 text_available_width = mVisibleTextRect.getWidth() - mHPad; // reserve room for margin
+ const F32 text_available_width = (F32)(mVisibleTextRect.getWidth() - mHPad); // reserve room for margin
F32 remaining_pixels = text_available_width;
S32 line_count = 0;
@@ -1874,7 +1880,7 @@ S32 LLTextBase::getLineNumFromDocIndex( S32 doc_index, bool include_wordwrap) co
line_list_t::const_iterator iter = std::upper_bound(mLineInfoList.begin(), mLineInfoList.end(), doc_index, line_end_compare());
if (include_wordwrap)
{
- return iter - mLineInfoList.begin();
+ return (S32)(iter - mLineInfoList.begin());
}
else
{
@@ -1911,7 +1917,7 @@ S32 LLTextBase::getFirstVisibleLine() const
// binary search for line that starts before top of visible buffer
line_list_t::const_iterator iter = std::lower_bound(mLineInfoList.begin(), mLineInfoList.end(), visible_region.mTop, compare_bottom());
- return iter - mLineInfoList.begin();
+ return (S32)(iter - mLineInfoList.begin());
}
std::pair<S32, S32> LLTextBase::getVisibleLines(bool require_fully_visible)
@@ -1933,7 +1939,7 @@ std::pair<S32, S32> LLTextBase::getVisibleLines(bool require_fully_visible)
first_iter = std::upper_bound(mLineInfoList.begin(), mLineInfoList.end(), visible_region.mTop, compare_bottom());
last_iter = std::lower_bound(mLineInfoList.begin(), mLineInfoList.end(), visible_region.mBottom, compare_top());
}
- return std::pair<S32, S32>(first_iter - mLineInfoList.begin(), last_iter - mLineInfoList.begin());
+ return std::pair<S32, S32>((S32)(first_iter - mLineInfoList.begin()), (S32)(last_iter - mLineInfoList.begin()));
}
@@ -2055,7 +2061,7 @@ LLTextBase::segment_set_t::const_iterator LLTextBase::getSegIterContaining(S32 i
LLTextSegmentPtr LLTextBase::getSegmentAtLocalPos( S32 x, S32 y, bool hit_past_end_of_line)
{
// Find the cursor position at the requested local screen position
- S32 offset = getDocIndexFromLocalCoord( x, y, FALSE, hit_past_end_of_line);
+ S32 offset = getDocIndexFromLocalCoord( x, y, false, hit_past_end_of_line);
segment_set_t::iterator seg_iter = getSegIterContaining(offset);
if (seg_iter != mSegments.end())
{
@@ -2196,8 +2202,8 @@ static LLUIImagePtr image_from_icon_name(const std::string& icon_name)
void LLTextBase::appendTextImpl(const std::string &new_text, const LLStyle::Params& input_params)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_UI;
- LLStyle::Params style_params(input_params);
- style_params.fillFrom(getStyleParams());
+ LLStyle::Params style_params(getStyleParams());
+ style_params.overwriteFrom(input_params);
S32 part = (S32)LLTextParser::WHOLE;
if (mParseHTML && !style_params.is_link) // Don't search for URLs inside a link segment (STORM-358).
@@ -2312,10 +2318,10 @@ void LLTextBase::setLabel(const LLStringExplicit& label)
resetLabel();
}
-BOOL LLTextBase::setLabelArg(const std::string& key, const LLStringExplicit& text )
+bool LLTextBase::setLabelArg(const std::string& key, const LLStringExplicit& text )
{
mLabel.setArg(key, text);
- return TRUE;
+ return true;
}
void LLTextBase::resetLabel()
@@ -2328,7 +2334,7 @@ void LLTextBase::resetLabel()
style->setColor(mTentativeFgColor);
LLStyleConstSP sp(style);
- LLTextSegmentPtr label = new LLLabelTextSegment(sp, 0, mLabel.getWString().length() + 1, *this);
+ LLTextSegmentPtr label = new LLLabelTextSegment(sp, 0, static_cast<S32>(mLabel.getWString().length()) + 1, *this);
insertSegment(label);
}
}
@@ -2388,7 +2394,7 @@ void LLTextBase::appendWidget(const LLInlineViewSegment::Params& params, const s
{
segment_vec_t segments;
LLWString widget_wide_text = utf8str_to_wstring(text);
- segments.push_back(new LLInlineViewSegment(params, getLength(), getLength() + widget_wide_text.size()));
+ segments.push_back(new LLInlineViewSegment(params, getLength(), getLength() + static_cast<S32>(widget_wide_text.size())));
insertStringNoUndo(getLength(), widget_wide_text, &segments);
}
@@ -2398,10 +2404,10 @@ void LLTextBase::appendAndHighlightTextImpl(const std::string &new_text, S32 hig
// Save old state
S32 selection_start = mSelectionStart;
S32 selection_end = mSelectionEnd;
- BOOL was_selecting = mIsSelecting;
+ bool was_selecting = mIsSelecting;
S32 cursor_pos = mCursorPos;
S32 old_length = getLength();
- BOOL cursor_was_at_end = (mCursorPos == old_length);
+ bool cursor_was_at_end = (mCursorPos == old_length);
deselect();
@@ -2411,16 +2417,14 @@ void LLTextBase::appendAndHighlightTextImpl(const std::string &new_text, S32 hig
{
LLStyle::Params highlight_params(style_params);
- LLSD pieces = LLTextParser::instance().parsePartialLineHighlights(new_text, highlight_params.color(), (LLTextParser::EHighlightPosition)highlight_part);
+ auto pieces = LLTextParser::instance().parsePartialLineHighlights(new_text, highlight_params.color, (LLTextParser::EHighlightPosition)highlight_part);
for (S32 i = 0; i < pieces.size(); i++)
{
- LLSD color_llsd = pieces[i]["color"];
- LLColor4 lcolor;
- lcolor.setValue(color_llsd);
- highlight_params.color = lcolor;
+ const auto& piece_pair = pieces[i];
+ highlight_params.color = piece_pair.second;
LLWString wide_text;
- wide_text = utf8str_to_wstring(pieces[i]["text"].asString());
+ wide_text = utf8str_to_wstring(piece_pair.first);
S32 cur_length = getLength();
LLStyleConstSP sp(new LLStyle(highlight_params));
@@ -2429,11 +2433,11 @@ void LLTextBase::appendAndHighlightTextImpl(const std::string &new_text, S32 hig
{
highlight_params.font.style("NORMAL");
LLStyleConstSP normal_sp(new LLStyle(highlight_params));
- segmentp = new LLOnHoverChangeableTextSegment(sp, normal_sp, cur_length, cur_length + wide_text.size(), *this);
+ segmentp = new LLOnHoverChangeableTextSegment(sp, normal_sp, cur_length, cur_length + static_cast<S32>(wide_text.size()), *this);
}
else
{
- segmentp = new LLNormalTextSegment(sp, cur_length, cur_length + wide_text.size(), *this);
+ segmentp = new LLNormalTextSegment(sp, cur_length, cur_length + static_cast<S32>(wide_text.size()), *this);
}
segment_vec_t segments;
segments.push_back(segmentp);
@@ -2447,7 +2451,7 @@ void LLTextBase::appendAndHighlightTextImpl(const std::string &new_text, S32 hig
segment_vec_t segments;
S32 segment_start = old_length;
- S32 segment_end = old_length + wide_text.size();
+ S32 segment_end = old_length + static_cast<S32>(wide_text.size());
LLStyleConstSP sp(new LLStyle(style_params));
if (underline_on_hover_only || mSkipLinkUnderline)
{
@@ -2538,7 +2542,7 @@ void LLTextBase::replaceUrl(const std::string &url,
S32 start = seg->getStart();
S32 end = seg->getEnd();
text = text.substr(0, start) + wlabel + text.substr(end, text.size() - end + 1);
- seg->setEnd(start + wlabel.size());
+ seg->setEnd(start + static_cast<S32>(wlabel.size()));
modified = true;
}
@@ -2586,7 +2590,7 @@ const LLWString& LLTextBase::getWText() const
// will be put to its right. If round is false, the cursor will always be put to the
// character's left.
-S32 LLTextBase::getDocIndexFromLocalCoord( S32 local_x, S32 local_y, BOOL round, bool hit_past_end_of_line) const
+S32 LLTextBase::getDocIndexFromLocalCoord( S32 local_x, S32 local_y, bool round, bool hit_past_end_of_line) const
{
// Figure out which line we're nearest to.
LLRect doc_rect = mDocumentView->getRect();
@@ -2601,7 +2605,7 @@ S32 LLTextBase::getDocIndexFromLocalCoord( S32 local_x, S32 local_y, BOOL round,
}
S32 pos = getLength();
- F32 start_x = line_iter->mRect.mLeft + doc_rect.mLeft;
+ F32 start_x = (F32)(line_iter->mRect.mLeft + doc_rect.mLeft);
segment_set_t::iterator line_seg_iter;
S32 line_seg_offset;
@@ -2619,7 +2623,7 @@ S32 LLTextBase::getDocIndexFromLocalCoord( S32 local_x, S32 local_y, BOOL round,
if(newline)
{
- pos = segment_line_start + segmentp->getOffset(local_x - start_x, line_seg_offset, segment_line_length, round);
+ pos = segment_line_start + segmentp->getOffset(local_x - (S32)start_x, line_seg_offset, segment_line_length, round);
break;
}
@@ -2649,7 +2653,7 @@ S32 LLTextBase::getDocIndexFromLocalCoord( S32 local_x, S32 local_y, BOOL round,
}
else
{
- offset = segmentp->getOffset(local_x - start_x, line_seg_offset, segment_line_length, round);
+ offset = segmentp->getOffset(local_x - (S32)start_x, line_seg_offset, segment_line_length, round);
}
pos = segment_line_start + offset;
break;
@@ -2696,7 +2700,7 @@ LLRect LLTextBase::getDocRectFromDocIndex(S32 pos) const
getSegmentAndOffset(line_iter->mDocIndexStart, &line_seg_iter, &line_seg_offset);
getSegmentAndOffset(pos, &cursor_seg_iter, &cursor_seg_offset);
- F32 doc_left_precise = line_iter->mRect.mLeft;
+ F32 doc_left_precise = (F32)line_iter->mRect.mLeft;
while(line_seg_iter != mSegments.end())
{
@@ -2727,7 +2731,7 @@ LLRect LLTextBase::getDocRectFromDocIndex(S32 pos) const
}
LLRect doc_rect;
- doc_rect.mLeft = doc_left_precise;
+ doc_rect.mLeft = (S32)doc_left_precise;
doc_rect.mBottom = line_iter->mRect.mBottom;
doc_rect.mTop = line_iter->mRect.mTop;
@@ -2866,7 +2870,7 @@ void LLTextBase::changeLine( S32 delta )
{
LLRect visible_region = getVisibleDocumentRect();
S32 new_cursor_pos = getDocIndexFromLocalCoord(mDesiredXPixel,
- mLineInfoList[new_line].mRect.mBottom + mVisibleTextRect.mBottom - visible_region.mBottom, TRUE);
+ mLineInfoList[new_line].mRect.mBottom + mVisibleTextRect.mBottom - visible_region.mBottom, true);
S32 actual_line = getLineNumFromDocIndex(new_cursor_pos);
if (actual_line != new_line)
{
@@ -2891,7 +2895,7 @@ bool LLTextBase::setCursor(S32 row, S32 column)
{
if (row < 0 || column < 0) return false;
- S32 n_lines = mLineInfoList.size();
+ S32 n_lines = static_cast<S32>(mLineInfoList.size());
for (S32 line = row; line < n_lines; ++line)
{
const line_info& li = mLineInfoList[line];
@@ -3129,7 +3133,7 @@ void LLTextBase::startSelection()
{
if( !mIsSelecting )
{
- mIsSelecting = TRUE;
+ mIsSelecting = true;
mSelectionStart = mCursorPos;
mSelectionEnd = mCursorPos;
}
@@ -3139,7 +3143,7 @@ void LLTextBase::endSelection()
{
if( mIsSelecting )
{
- mIsSelecting = FALSE;
+ mIsSelecting = false;
mSelectionEnd = mCursorPos;
}
}
@@ -3240,25 +3244,25 @@ F32 LLTextSegment::draw(S32 start, S32 end, S32 selection_start, S32 selection_e
bool LLTextSegment::canEdit() const { return false; }
void LLTextSegment::unlinkFromDocument(LLTextBase*) {}
void LLTextSegment::linkToDocument(LLTextBase*) {}
-const LLColor4& LLTextSegment::getColor() const { return LLColor4::white; }
-//void LLTextSegment::setColor(const LLColor4 &color) {}
+const LLUIColor& LLTextSegment::getColor() const { static const LLUIColor white = LLUIColorTable::instance().getColor("White", LLColor4::white); return white; }
+//void LLTextSegment::setColor(const LLUIColor &color) {}
LLStyleConstSP LLTextSegment::getStyle() const {static LLStyleConstSP sp(new LLStyle()); return sp; }
void LLTextSegment::setStyle(LLStyleConstSP style) {}
void LLTextSegment::setToken( LLKeywordToken* token ) {}
LLKeywordToken* LLTextSegment::getToken() const { return NULL; }
void LLTextSegment::setToolTip( const std::string &msg ) {}
void LLTextSegment::dump() const {}
-BOOL LLTextSegment::handleMouseDown(S32 x, S32 y, MASK mask) { return FALSE; }
-BOOL LLTextSegment::handleMouseUp(S32 x, S32 y, MASK mask) { return FALSE; }
-BOOL LLTextSegment::handleMiddleMouseDown(S32 x, S32 y, MASK mask) { return FALSE; }
-BOOL LLTextSegment::handleMiddleMouseUp(S32 x, S32 y, MASK mask) { return FALSE; }
-BOOL LLTextSegment::handleRightMouseDown(S32 x, S32 y, MASK mask) { return FALSE; }
-BOOL LLTextSegment::handleRightMouseUp(S32 x, S32 y, MASK mask) { return FALSE; }
-BOOL LLTextSegment::handleDoubleClick(S32 x, S32 y, MASK mask) { return FALSE; }
-BOOL LLTextSegment::handleHover(S32 x, S32 y, MASK mask) { return FALSE; }
-BOOL LLTextSegment::handleScrollWheel(S32 x, S32 y, S32 clicks) { return FALSE; }
-BOOL LLTextSegment::handleScrollHWheel(S32 x, S32 y, S32 clicks) { return FALSE; }
-BOOL LLTextSegment::handleToolTip(S32 x, S32 y, MASK mask) { return FALSE; }
+bool LLTextSegment::handleMouseDown(S32 x, S32 y, MASK mask) { return false; }
+bool LLTextSegment::handleMouseUp(S32 x, S32 y, MASK mask) { return false; }
+bool LLTextSegment::handleMiddleMouseDown(S32 x, S32 y, MASK mask) { return false; }
+bool LLTextSegment::handleMiddleMouseUp(S32 x, S32 y, MASK mask) { return false; }
+bool LLTextSegment::handleRightMouseDown(S32 x, S32 y, MASK mask) { return false; }
+bool LLTextSegment::handleRightMouseUp(S32 x, S32 y, MASK mask) { return false; }
+bool LLTextSegment::handleDoubleClick(S32 x, S32 y, MASK mask) { return false; }
+bool LLTextSegment::handleHover(S32 x, S32 y, MASK mask) { return false; }
+bool LLTextSegment::handleScrollWheel(S32 x, S32 y, S32 clicks) { return false; }
+bool LLTextSegment::handleScrollHWheel(S32 x, S32 y, S32 clicks) { return false; }
+bool LLTextSegment::handleToolTip(S32 x, S32 y, MASK mask) { return false; }
const std::string& LLTextSegment::getName() const
{
return LLStringUtil::null;
@@ -3266,7 +3270,7 @@ const std::string& LLTextSegment::getName() const
void LLTextSegment::onMouseCaptureLost() {}
void LLTextSegment::screenPointToLocal(S32 screen_x, S32 screen_y, S32* local_x, S32* local_y) const {}
void LLTextSegment::localPointToScreen(S32 local_x, S32 local_y, S32* screen_x, S32* screen_y) const {}
-BOOL LLTextSegment::hasMouseCapture() { return FALSE; }
+bool LLTextSegment::hasMouseCapture() { return false; }
//
// LLNormalTextSegment
@@ -3287,7 +3291,7 @@ LLNormalTextSegment::LLNormalTextSegment( LLStyleConstSP style, S32 start, S32 e
}
}
-LLNormalTextSegment::LLNormalTextSegment( const LLColor4& color, S32 start, S32 end, LLTextBase& editor, BOOL is_visible)
+LLNormalTextSegment::LLNormalTextSegment( const LLUIColor& color, S32 start, S32 end, LLTextBase& editor, bool is_visible)
: LLTextSegment(start, end),
mToken(NULL),
mEditor(editor)
@@ -3327,7 +3331,7 @@ F32 LLNormalTextSegment::drawClippedSegment(S32 seg_start, S32 seg_end, S32 sele
const LLFontGL* font = mStyle->getFont();
- LLColor4 color = (mEditor.getReadOnly() ? mStyle->getReadOnlyColor() : mStyle->getColor()) % alpha;
+ LLColor4 color = (mEditor.getReadOnly() ? mStyle->getReadOnlyColor() : mStyle->getColor()) % (alpha * mStyle->getAlpha());
if( selection_start > seg_start )
{
@@ -3387,7 +3391,7 @@ F32 LLNormalTextSegment::drawClippedSegment(S32 seg_start, S32 seg_end, S32 sele
return right_x;
}
-BOOL LLNormalTextSegment::handleHover(S32 x, S32 y, MASK mask)
+bool LLNormalTextSegment::handleHover(S32 x, S32 y, MASK mask)
{
if (getStyle() && getStyle()->isLink())
{
@@ -3395,13 +3399,13 @@ BOOL LLNormalTextSegment::handleHover(S32 x, S32 y, MASK mask)
if(mEditor.getSegmentAtLocalPos(x, y, false) == this)
{
LLUI::getInstance()->getWindow()->setCursor(UI_CURSOR_HAND);
- return TRUE;
+ return true;
}
}
- return FALSE;
+ return false;
}
-BOOL LLNormalTextSegment::handleRightMouseDown(S32 x, S32 y, MASK mask)
+bool LLNormalTextSegment::handleRightMouseDown(S32 x, S32 y, MASK mask)
{
if (getStyle() && getStyle()->isLink())
{
@@ -3409,13 +3413,13 @@ BOOL LLNormalTextSegment::handleRightMouseDown(S32 x, S32 y, MASK mask)
if(mEditor.getSegmentAtLocalPos(x, y, false) == this)
{
mEditor.createUrlContextMenu(x, y, getStyle()->getLinkHREF());
- return TRUE;
+ return true;
}
}
- return FALSE;
+ return false;
}
-BOOL LLNormalTextSegment::handleMouseDown(S32 x, S32 y, MASK mask)
+bool LLNormalTextSegment::handleMouseDown(S32 x, S32 y, MASK mask)
{
if (getStyle() && getStyle()->isLink())
{
@@ -3423,14 +3427,14 @@ BOOL LLNormalTextSegment::handleMouseDown(S32 x, S32 y, MASK mask)
if(mEditor.getSegmentAtLocalPos(x, y, false) == this)
{
// eat mouse down event on hyperlinks, so we get the mouse up
- return TRUE;
+ return true;
}
}
- return FALSE;
+ return false;
}
-BOOL LLNormalTextSegment::handleMouseUp(S32 x, S32 y, MASK mask)
+bool LLNormalTextSegment::handleMouseUp(S32 x, S32 y, MASK mask)
{
if (getStyle() && getStyle()->isLink())
{
@@ -3446,14 +3450,14 @@ BOOL LLNormalTextSegment::handleMouseUp(S32 x, S32 y, MASK mask)
{
LLUrlAction::openURLExternal(url);
}
- return TRUE;
+ return true;
}
}
- return FALSE;
+ return false;
}
-BOOL LLNormalTextSegment::handleToolTip(S32 x, S32 y, MASK mask)
+bool LLNormalTextSegment::handleToolTip(S32 x, S32 y, MASK mask)
{
std::string msg;
// do we have a tooltip for a loaded keyword (for script editor)?
@@ -3461,16 +3465,16 @@ BOOL LLNormalTextSegment::handleToolTip(S32 x, S32 y, MASK mask)
{
const LLWString& wmsg = mToken->getToolTip();
LLToolTipMgr::instance().show(wstring_to_utf8str(wmsg), (mToken->getType() == LLKeywordToken::TT_FUNCTION));
- return TRUE;
+ return true;
}
// or do we have an explicitly set tooltip (e.g., for Urls)
if (!mTooltip.empty())
{
LLToolTipMgr::instance().show(mTooltip);
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
void LLNormalTextSegment::setToolTip(const std::string& tooltip)
@@ -3530,7 +3534,7 @@ S32 LLNormalTextSegment::getNumChars(S32 num_pixels, S32 segment_offset, S32 lin
: LLFontGL::ONLY_WORD_BOUNDARIES;
- S32 offsetLength = text.length() - (segment_offset + mStart);
+ S32 offsetLength = static_cast<S32>(text.length()) - (segment_offset + mStart);
if(getLength() < segment_offset + mStart)
{
@@ -3572,9 +3576,9 @@ S32 LLNormalTextSegment::getNumChars(S32 num_pixels, S32 segment_offset, S32 lin
void LLNormalTextSegment::dump() const
{
LL_INFOS() << "Segment [" <<
-// mColor.mV[VX] << ", " <<
-// mColor.mV[VY] << ", " <<
-// mColor.mV[VZ] << "]\t[" <<
+// mColor.mV[VRED] << ", " <<
+// mColor.mV[VGREEN] << ", " <<
+// mColor.mV[VBLUE] << "]\t[" <<
mStart << ", " <<
getEnd() << "]" <<
LL_ENDL;
@@ -3597,7 +3601,7 @@ LLLabelTextSegment::LLLabelTextSegment( LLStyleConstSP style, S32 start, S32 end
{
}
-LLLabelTextSegment::LLLabelTextSegment( const LLColor4& color, S32 start, S32 end, LLTextBase& editor, BOOL is_visible)
+LLLabelTextSegment::LLLabelTextSegment( const LLUIColor& color, S32 start, S32 end, LLTextBase& editor, bool is_visible)
: LLNormalTextSegment(color, start, end, editor, is_visible)
{
}
@@ -3610,7 +3614,7 @@ const LLWString& LLLabelTextSegment::getWText() const
/*virtual*/
const S32 LLLabelTextSegment::getLength() const
{
- return mEditor.getWlabel().length();
+ return static_cast<S32>(mEditor.getWlabel().length());
}
//
@@ -3621,12 +3625,12 @@ LLEmojiTextSegment::LLEmojiTextSegment(LLStyleConstSP style, S32 start, S32 end,
{
}
-LLEmojiTextSegment::LLEmojiTextSegment(const LLColor4& color, S32 start, S32 end, LLTextBase& editor, BOOL is_visible)
+LLEmojiTextSegment::LLEmojiTextSegment(const LLUIColor& color, S32 start, S32 end, LLTextBase& editor, bool is_visible)
: LLNormalTextSegment(color, start, end, editor, is_visible)
{
}
-BOOL LLEmojiTextSegment::handleToolTip(S32 x, S32 y, MASK mask)
+bool LLEmojiTextSegment::handleToolTip(S32 x, S32 y, MASK mask)
{
if (mTooltip.empty())
{
@@ -3661,7 +3665,7 @@ F32 LLOnHoverChangeableTextSegment::draw(S32 start, S32 end, S32 selection_start
}
/*virtual*/
-BOOL LLOnHoverChangeableTextSegment::handleHover(S32 x, S32 y, MASK mask)
+bool LLOnHoverChangeableTextSegment::handleHover(S32 x, S32 y, MASK mask)
{
mStyle = mEditor.getSkipLinkUnderline() ? mNormalStyle : mHoveredStyle;
return LLNormalTextSegment::handleHover(x, y, mask);
@@ -3713,7 +3717,7 @@ bool LLInlineViewSegment::getDimensionsF32(S32 first_char, S32 num_chars, F32& w
}
else
{
- width = mLeftPad + mRightPad + mView->getRect().getWidth();
+ width = (F32)(mLeftPad + mRightPad + mView->getRect().getWidth());
height = mBottomPad + mTopPad + mView->getRect().getHeight();
}
@@ -3836,15 +3840,15 @@ S32 LLImageTextSegment::getNumChars(S32 num_pixels, S32 segment_offset, S32 lin
return 0;
}
-BOOL LLImageTextSegment::handleToolTip(S32 x, S32 y, MASK mask)
+bool LLImageTextSegment::handleToolTip(S32 x, S32 y, MASK mask)
{
if (!mTooltip.empty())
{
LLToolTipMgr::instance().show(mTooltip);
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
void LLImageTextSegment::setToolTip(const std::string& tooltip)
@@ -3864,10 +3868,10 @@ F32 LLImageTextSegment::draw(S32 start, S32 end, S32 selection_start, S32 select
S32 style_image_width = image->getWidth();
// Text is drawn from the top of the draw_rect downward
- S32 text_center = draw_rect.mTop - (draw_rect.getHeight() / 2);
+ S32 text_center = (S32)(draw_rect.mTop - (draw_rect.getHeight() / 2.f));
// Align image to center of draw rect
S32 image_bottom = text_center - (style_image_height / 2);
- image->draw(draw_rect.mLeft, image_bottom,
+ image->draw((S32)draw_rect.mLeft, image_bottom,
style_image_width, style_image_height, color);
const S32 IMAGE_HPAD = 3;