diff options
author | Leyla Farazha <leyla@lindenlab.com> | 2010-07-19 17:22:12 -0700 |
---|---|---|
committer | Leyla Farazha <leyla@lindenlab.com> | 2010-07-19 17:22:12 -0700 |
commit | d603085c0332f5d615cc6583e13ed0aa5ab21908 (patch) | |
tree | bac8d5e6b99643448579060d38a2e69fab65caf7 /indra/llui/lltextbase.cpp | |
parent | 474457ea7ea1bd178682788426a4cf40c3fffdcd (diff) | |
parent | 4339600d43601f07d01c676cce5da17c2758c4cb (diff) |
Merge with dessie/viewer-release
Diffstat (limited to 'indra/llui/lltextbase.cpp')
-rw-r--r-- | indra/llui/lltextbase.cpp | 56 |
1 files changed, 43 insertions, 13 deletions
diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index c62d699c7e..04efef606e 100644 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -66,7 +66,10 @@ bool LLTextBase::compare_segment_end::operator()(const LLTextSegmentPtr& a, cons { return a->getStart() < b->getStart(); } - return a->getEnd() < b->getEnd(); + else + { + return a->getEnd() < b->getEnd(); + } } @@ -174,7 +177,7 @@ LLTextBase::Params::Params() LLTextBase::LLTextBase(const LLTextBase::Params &p) : LLUICtrl(p, LLTextViewModelPtr(new LLTextViewModel)), - mURLClickSignal(), + mURLClickSignal(NULL), mMaxTextByteLength( p.max_text_length ), mDefaultFont(p.font), mFontShadow(p.font_shadow), @@ -209,7 +212,8 @@ LLTextBase::LLTextBase(const LLTextBase::Params &p) mParseHTML(p.allow_html), mParseHighlights(p.parse_highlights), mBGVisible(p.bg_visible), - mScroller(NULL) + mScroller(NULL), + mStyleDirty(true) { if(p.allow_scroll) { @@ -248,9 +252,8 @@ LLTextBase::LLTextBase(const LLTextBase::Params &p) LLTextBase::~LLTextBase() { - // Menu, like any other LLUICtrl, is deleted by its parent - gMenuHolder - mSegments.clear(); + delete mURLClickSignal; } void LLTextBase::initFromParams(const LLTextBase::Params& p) @@ -296,13 +299,18 @@ bool LLTextBase::truncate() return did_truncate; } -LLStyle::Params LLTextBase::getDefaultStyleParams() +const LLStyle::Params& LLTextBase::getDefaultStyleParams() { - return LLStyle::Params() - .color(LLUIColor(&mFgColor)) - .readonly_color(LLUIColor(&mReadOnlyFgColor)) - .font(mDefaultFont) - .drop_shadow(mFontShadow); + if (mStyleDirty) + { + mDefaultStyle + .color(LLUIColor(&mFgColor)) + .readonly_color(LLUIColor(&mReadOnlyFgColor)) + .font(mDefaultFont) + .drop_shadow(mFontShadow); + mStyleDirty = false; + } + return mDefaultStyle; } void LLTextBase::onValueChange(S32 start, S32 end) @@ -861,11 +869,12 @@ BOOL LLTextBase::handleMouseUp(S32 x, S32 y, MASK mask) if (cur_segment && cur_segment->handleMouseUp(x, y, mask)) { // Did we just click on a link? - if (cur_segment->getStyle() + if (mURLClickSignal + && cur_segment->getStyle() && cur_segment->getStyle()->isLink()) { // *TODO: send URL here? - mURLClickSignal(this, LLSD() ); + (*mURLClickSignal)(this, LLSD() ); } return TRUE; } @@ -1039,12 +1048,14 @@ void LLTextBase::draw() void LLTextBase::setColor( const LLColor4& c ) { mFgColor = c; + mStyleDirty = true; } //virtual void LLTextBase::setReadOnlyColor(const LLColor4 &c) { mReadOnlyFgColor = c; + mStyleDirty = true; } //virtual @@ -1488,12 +1499,22 @@ void LLTextBase::getSegmentAndOffset( S32 startpos, segment_set_t::iterator* seg LLTextBase::segment_set_t::iterator LLTextBase::getSegIterContaining(S32 index) { + if (index > getLength()) { return mSegments.end(); } + + // when there are no segments, we return the end iterator, which must be checked by caller + if (mSegments.size() <= 1) { return mSegments.begin(); } + segment_set_t::iterator it = mSegments.upper_bound(new LLIndexSegment(index)); return it; } LLTextBase::segment_set_t::const_iterator LLTextBase::getSegIterContaining(S32 index) const { + if (index > getLength()) { return mSegments.end(); } + + // when there are no segments, we return the end iterator, which must be checked by caller + if (mSegments.size() <= 1) { return mSegments.begin(); } + LLTextBase::segment_set_t::const_iterator it = mSegments.upper_bound(new LLIndexSegment(index)); return it; } @@ -2346,6 +2367,15 @@ LLRect LLTextBase::getVisibleDocumentRect() const } } +boost::signals2::connection LLTextBase::setURLClickedCallback(const commit_signal_t::slot_type& cb) +{ + if (!mURLClickSignal) + { + mURLClickSignal = new commit_signal_t(); + } + return mURLClickSignal->connect(cb); +} + // // LLTextSegment // |