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.cpp171
1 files changed, 89 insertions, 82 deletions
diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp
index 50feee8a47..349a001335 100644
--- a/indra/llui/lltextbase.cpp
+++ b/indra/llui/lltextbase.cpp
@@ -206,7 +206,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),
@@ -223,7 +223,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 ),
@@ -307,7 +307,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))
@@ -334,7 +334,7 @@ bool LLTextBase::truncate()
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;
+ did_truncate = true;
}
}
@@ -845,7 +845,14 @@ S32 LLTextBase::insertStringNoUndo(S32 pos, const LLWString &wstr, LLTextBase::s
S32 old_len = getLength(); // length() returns character length
S32 insert_len = wstr.length();
- pos = getEditableIndex(pos, true);
+ 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);
@@ -1108,14 +1115,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);
@@ -1143,27 +1150,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))
@@ -1176,62 +1183,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();
@@ -1244,43 +1251,43 @@ 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);
@@ -1300,7 +1307,7 @@ const std::string LLTextBase::getToolTip() const
}
//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)
{
@@ -1376,7 +1383,7 @@ void LLTextBase::draw()
: 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
@@ -1387,7 +1394,7 @@ void LLTextBase::draw()
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;
@@ -1408,9 +1415,9 @@ void LLTextBase::draw()
drawCursor();
}
- mDocumentView->setVisibleDirect(FALSE);
+ mDocumentView->setVisibleDirect(false);
LLUICtrl::draw();
- mDocumentView->setVisibleDirect(TRUE);
+ mDocumentView->setVisibleDirect(true);
}
@@ -1429,7 +1436,7 @@ void LLTextBase::setReadOnlyColor(const LLColor4 &c)
}
//virtual
-void LLTextBase::onVisibilityChange( BOOL new_visibility )
+void LLTextBase::onVisibilityChange( bool new_visibility )
{
LLContextMenu* menu = static_cast<LLContextMenu*>(mPopupMenuHandle.get());
if(!new_visibility && menu)
@@ -1446,7 +1453,7 @@ void LLTextBase::setValue(const LLSD& value )
}
//virtual
-BOOL LLTextBase::canDeselect() const
+bool LLTextBase::canDeselect() const
{
return hasSelection();
}
@@ -1457,7 +1464,7 @@ void LLTextBase::deselect()
{
mSelectionStart = 0;
mSelectionEnd = 0;
- mIsSelecting = FALSE;
+ mIsSelecting = false;
}
bool LLTextBase::getSpellCheck() const
@@ -1585,7 +1592,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();
@@ -2065,7 +2072,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())
{
@@ -2322,10 +2329,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()
@@ -2408,10 +2415,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();
@@ -2596,7 +2603,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();
@@ -2876,7 +2883,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)
{
@@ -3139,7 +3146,7 @@ void LLTextBase::startSelection()
{
if( !mIsSelecting )
{
- mIsSelecting = TRUE;
+ mIsSelecting = true;
mSelectionStart = mCursorPos;
mSelectionEnd = mCursorPos;
}
@@ -3149,7 +3156,7 @@ void LLTextBase::endSelection()
{
if( mIsSelecting )
{
- mIsSelecting = FALSE;
+ mIsSelecting = false;
mSelectionEnd = mCursorPos;
}
}
@@ -3258,17 +3265,17 @@ 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;
@@ -3276,7 +3283,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
@@ -3297,7 +3304,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 LLColor4& color, S32 start, S32 end, LLTextBase& editor, bool is_visible)
: LLTextSegment(start, end),
mToken(NULL),
mEditor(editor)
@@ -3397,7 +3404,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())
{
@@ -3405,13 +3412,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())
{
@@ -3419,13 +3426,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())
{
@@ -3433,14 +3440,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())
{
@@ -3456,14 +3463,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)?
@@ -3471,16 +3478,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)
@@ -3607,7 +3614,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 LLColor4& color, S32 start, S32 end, LLTextBase& editor, bool is_visible)
: LLNormalTextSegment(color, start, end, editor, is_visible)
{
}
@@ -3631,12 +3638,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 LLColor4& 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())
{
@@ -3671,7 +3678,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);
@@ -3846,15 +3853,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)