diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/llui/lltexteditor.cpp | 92 |
1 files changed, 47 insertions, 45 deletions
diff --git a/linden/indra/llui/lltexteditor.cpp b/linden/indra/llui/lltexteditor.cpp index 4ed936f..71522e5 100644 --- a/linden/indra/llui/lltexteditor.cpp +++ b/linden/indra/llui/lltexteditor.cpp | |||
@@ -37,7 +37,7 @@ | |||
37 | 37 | ||
38 | #include "llfontgl.h" | 38 | #include "llfontgl.h" |
39 | #include "llgl.h" | 39 | #include "llgl.h" |
40 | #include "llglimmediate.h" | 40 | #include "llrender.h" |
41 | #include "llui.h" | 41 | #include "llui.h" |
42 | #include "lluictrlfactory.h" | 42 | #include "lluictrlfactory.h" |
43 | #include "llrect.h" | 43 | #include "llrect.h" |
@@ -1244,14 +1244,14 @@ BOOL LLTextEditor::handleHover(S32 x, S32 y, MASK mask) | |||
1244 | const LLTextSegment* cur_segment = getSegmentAtLocalPos( x, y ); | 1244 | const LLTextSegment* cur_segment = getSegmentAtLocalPos( x, y ); |
1245 | if( cur_segment ) | 1245 | if( cur_segment ) |
1246 | { | 1246 | { |
1247 | if(cur_segment->getStyle().isLink()) | 1247 | if(cur_segment->getStyle()->isLink()) |
1248 | { | 1248 | { |
1249 | lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (over link, inactive)" << llendl; | 1249 | lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (over link, inactive)" << llendl; |
1250 | getWindow()->setCursor(UI_CURSOR_HAND); | 1250 | getWindow()->setCursor(UI_CURSOR_HAND); |
1251 | handled = TRUE; | 1251 | handled = TRUE; |
1252 | } | 1252 | } |
1253 | else | 1253 | else |
1254 | if(cur_segment->getStyle().getIsEmbeddedItem()) | 1254 | if(cur_segment->getStyle()->getIsEmbeddedItem()) |
1255 | { | 1255 | { |
1256 | lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (over embedded item, inactive)" << llendl; | 1256 | lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (over embedded item, inactive)" << llendl; |
1257 | getWindow()->setCursor(UI_CURSOR_HAND); | 1257 | getWindow()->setCursor(UI_CURSOR_HAND); |
@@ -2928,23 +2928,26 @@ void LLTextEditor::drawText() | |||
2928 | S32 clipped_len = clipped_end - seg_start; | 2928 | S32 clipped_len = clipped_end - seg_start; |
2929 | if( clipped_len > 0 ) | 2929 | if( clipped_len > 0 ) |
2930 | { | 2930 | { |
2931 | LLStyle style = cur_segment->getStyle(); | 2931 | LLStyleSP style = cur_segment->getStyle(); |
2932 | if ( style.isImage() && (cur_segment->getStart() >= seg_start) && (cur_segment->getStart() <= clipped_end)) | 2932 | if ( style->isImage() && (cur_segment->getStart() >= seg_start) && (cur_segment->getStart() <= clipped_end)) |
2933 | { | 2933 | { |
2934 | LLUIImagePtr image = style.getImage(); | 2934 | S32 style_image_height = style->mImageHeight; |
2935 | image->draw(llround(text_x), llround(text_y)+line_height-style.mImageHeight, style.mImageWidth, style.mImageHeight); | 2935 | S32 style_image_width = style->mImageWidth; |
2936 | LLUIImagePtr image = style->getImage(); | ||
2937 | image->draw(llround(text_x), llround(text_y)+line_height-style_image_height, | ||
2938 | style_image_width, style_image_height); | ||
2936 | } | 2939 | } |
2937 | 2940 | ||
2938 | if (cur_segment == mHoverSegment && style.getIsEmbeddedItem()) | 2941 | if (cur_segment == mHoverSegment && style->getIsEmbeddedItem()) |
2939 | { | 2942 | { |
2940 | style.mUnderline = TRUE; | 2943 | style->mUnderline = TRUE; |
2941 | } | 2944 | } |
2942 | 2945 | ||
2943 | S32 left_pos = llmin( mSelectionStart, mSelectionEnd ); | 2946 | S32 left_pos = llmin( mSelectionStart, mSelectionEnd ); |
2944 | 2947 | ||
2945 | if ( (mParseHTML) && (left_pos > seg_start) && (left_pos < clipped_end) && mIsSelecting && (mSelectionStart == mSelectionEnd) ) | 2948 | if ( (mParseHTML) && (left_pos > seg_start) && (left_pos < clipped_end) && mIsSelecting && (mSelectionStart == mSelectionEnd) ) |
2946 | { | 2949 | { |
2947 | mHTML = style.getLinkHREF(); | 2950 | mHTML = style->getLinkHREF(); |
2948 | } | 2951 | } |
2949 | 2952 | ||
2950 | drawClippedSegment( text, seg_start, clipped_end, text_x, text_y, selection_left, selection_right, style, &text_x ); | 2953 | drawClippedSegment( text, seg_start, clipped_end, text_x, text_y, selection_left, selection_right, style, &text_x ); |
@@ -2963,38 +2966,38 @@ void LLTextEditor::drawText() | |||
2963 | } | 2966 | } |
2964 | 2967 | ||
2965 | // Draws a single text segment, reversing the color for selection if needed. | 2968 | // Draws a single text segment, reversing the color for selection if needed. |
2966 | void LLTextEditor::drawClippedSegment(const LLWString &text, S32 seg_start, S32 seg_end, F32 x, F32 y, S32 selection_left, S32 selection_right, const LLStyle& style, F32* right_x ) | 2969 | void LLTextEditor::drawClippedSegment(const LLWString &text, S32 seg_start, S32 seg_end, F32 x, F32 y, S32 selection_left, S32 selection_right, const LLStyleSP& style, F32* right_x ) |
2967 | { | 2970 | { |
2968 | if (!style.isVisible()) | 2971 | if (!style->isVisible()) |
2969 | { | 2972 | { |
2970 | return; | 2973 | return; |
2971 | } | 2974 | } |
2972 | 2975 | ||
2973 | const LLFontGL* font = mGLFont; | 2976 | const LLFontGL* font = mGLFont; |
2974 | 2977 | ||
2975 | LLColor4 color = style.getColor(); | 2978 | LLColor4 color = style->getColor(); |
2976 | 2979 | ||
2977 | if ( style.getFontString()[0] ) | 2980 | if ( style->getFontString()[0] ) |
2978 | { | 2981 | { |
2979 | font = LLResMgr::getInstance()->getRes(style.getFontID()); | 2982 | font = LLResMgr::getInstance()->getRes(style->getFontID()); |
2980 | } | 2983 | } |
2981 | 2984 | ||
2982 | U8 font_flags = LLFontGL::NORMAL; | 2985 | U8 font_flags = LLFontGL::NORMAL; |
2983 | 2986 | ||
2984 | if (style.mBold) | 2987 | if (style->mBold) |
2985 | { | 2988 | { |
2986 | font_flags |= LLFontGL::BOLD; | 2989 | font_flags |= LLFontGL::BOLD; |
2987 | } | 2990 | } |
2988 | if (style.mItalic) | 2991 | if (style->mItalic) |
2989 | { | 2992 | { |
2990 | font_flags |= LLFontGL::ITALIC; | 2993 | font_flags |= LLFontGL::ITALIC; |
2991 | } | 2994 | } |
2992 | if (style.mUnderline) | 2995 | if (style->mUnderline) |
2993 | { | 2996 | { |
2994 | font_flags |= LLFontGL::UNDERLINE; | 2997 | font_flags |= LLFontGL::UNDERLINE; |
2995 | } | 2998 | } |
2996 | 2999 | ||
2997 | if (style.getIsEmbeddedItem()) | 3000 | if (style->getIsEmbeddedItem()) |
2998 | { | 3001 | { |
2999 | if (mReadOnly) | 3002 | if (mReadOnly) |
3000 | { | 3003 | { |
@@ -3434,17 +3437,17 @@ void LLTextEditor::appendColoredText(const LLString &new_text, | |||
3434 | const LLColor4 &color, | 3437 | const LLColor4 &color, |
3435 | const LLString& font_name) | 3438 | const LLString& font_name) |
3436 | { | 3439 | { |
3437 | LLStyle style; | 3440 | LLStyleSP style(new LLStyle); |
3438 | style.setVisible(true); | 3441 | style->setVisible(true); |
3439 | style.setColor(color); | 3442 | style->setColor(color); |
3440 | style.setFontName(font_name); | 3443 | style->setFontName(font_name); |
3441 | appendStyledText(new_text, allow_undo, prepend_newline, &style); | 3444 | appendStyledText(new_text, allow_undo, prepend_newline, &style); |
3442 | } | 3445 | } |
3443 | 3446 | ||
3444 | void LLTextEditor::appendStyledText(const LLString &new_text, | 3447 | void LLTextEditor::appendStyledText(const LLString &new_text, |
3445 | bool allow_undo, | 3448 | bool allow_undo, |
3446 | bool prepend_newline, | 3449 | bool prepend_newline, |
3447 | const LLStyle* style) | 3450 | const LLStyleSP *stylep) |
3448 | { | 3451 | { |
3449 | if(mParseHTML) | 3452 | if(mParseHTML) |
3450 | { | 3453 | { |
@@ -3453,17 +3456,17 @@ void LLTextEditor::appendStyledText(const LLString &new_text, | |||
3453 | LLString text = new_text; | 3456 | LLString text = new_text; |
3454 | while ( findHTML(text, &start, &end) ) | 3457 | while ( findHTML(text, &start, &end) ) |
3455 | { | 3458 | { |
3456 | LLStyle html; | 3459 | LLStyleSP html(new LLStyle); |
3457 | html.setVisible(true); | 3460 | html->setVisible(true); |
3458 | html.setColor(mLinkColor); | 3461 | html->setColor(mLinkColor); |
3459 | if (style) | 3462 | if (stylep) |
3460 | { | 3463 | { |
3461 | html.setFontName(style->getFontString()); | 3464 | html->setFontName((*stylep)->getFontString()); |
3462 | } | 3465 | } |
3463 | html.mUnderline = TRUE; | 3466 | html->mUnderline = TRUE; |
3464 | 3467 | ||
3465 | if (start > 0) appendText(text.substr(0,start),allow_undo, prepend_newline, style); | 3468 | if (start > 0) appendText(text.substr(0,start),allow_undo, prepend_newline, stylep); |
3466 | html.setLinkHREF(text.substr(start,end-start)); | 3469 | html->setLinkHREF(text.substr(start,end-start)); |
3467 | appendText(text.substr(start, end-start),allow_undo, prepend_newline, &html); | 3470 | appendText(text.substr(start, end-start),allow_undo, prepend_newline, &html); |
3468 | if (end < (S32)text.length()) | 3471 | if (end < (S32)text.length()) |
3469 | { | 3472 | { |
@@ -3475,17 +3478,17 @@ void LLTextEditor::appendStyledText(const LLString &new_text, | |||
3475 | break; | 3478 | break; |
3476 | } | 3479 | } |
3477 | } | 3480 | } |
3478 | if (end < (S32)text.length()) appendText(text,allow_undo, prepend_newline, style); | 3481 | if (end < (S32)text.length()) appendText(text,allow_undo, prepend_newline, stylep); |
3479 | } | 3482 | } |
3480 | else | 3483 | else |
3481 | { | 3484 | { |
3482 | appendText(new_text, allow_undo, prepend_newline, style); | 3485 | appendText(new_text, allow_undo, prepend_newline, stylep); |
3483 | } | 3486 | } |
3484 | } | 3487 | } |
3485 | 3488 | ||
3486 | // Appends new text to end of document | 3489 | // Appends new text to end of document |
3487 | void LLTextEditor::appendText(const LLString &new_text, bool allow_undo, bool prepend_newline, | 3490 | void LLTextEditor::appendText(const LLString &new_text, bool allow_undo, bool prepend_newline, |
3488 | const LLStyle* segment_style) | 3491 | const LLStyleSP *stylep) |
3489 | { | 3492 | { |
3490 | // Save old state | 3493 | // Save old state |
3491 | BOOL was_scrolled_to_bottom = (mScrollbar->getDocPos() == mScrollbar->getDocPosMax()); | 3494 | BOOL was_scrolled_to_bottom = (mScrollbar->getDocPos() == mScrollbar->getDocPosMax()); |
@@ -3513,11 +3516,11 @@ void LLTextEditor::appendText(const LLString &new_text, bool allow_undo, bool pr | |||
3513 | append(utf8str_to_wstring(new_text), TRUE ); | 3516 | append(utf8str_to_wstring(new_text), TRUE ); |
3514 | } | 3517 | } |
3515 | 3518 | ||
3516 | if (segment_style) | 3519 | if (stylep) |
3517 | { | 3520 | { |
3518 | S32 segment_start = old_length; | 3521 | S32 segment_start = old_length; |
3519 | S32 segment_end = getLength(); | 3522 | S32 segment_end = getLength(); |
3520 | LLTextSegment* segment = new LLTextSegment(*segment_style, segment_start, segment_end ); | 3523 | LLTextSegment* segment = new LLTextSegment(*stylep, segment_start, segment_end ); |
3521 | mSegments.push_back(segment); | 3524 | mSegments.push_back(segment); |
3522 | } | 3525 | } |
3523 | 3526 | ||
@@ -3803,8 +3806,8 @@ void LLTextEditor::findEmbeddedItemSegments() | |||
3803 | in_text = TRUE; | 3806 | in_text = TRUE; |
3804 | } | 3807 | } |
3805 | 3808 | ||
3806 | LLStyle embedded_style; | 3809 | LLStyleSP embedded_style(new LLStyle); |
3807 | embedded_style.setIsEmbeddedItem( TRUE ); | 3810 | embedded_style->setIsEmbeddedItem( TRUE ); |
3808 | 3811 | ||
3809 | // Start with i just after the first embedded item | 3812 | // Start with i just after the first embedded item |
3810 | while ( text[idx] ) | 3813 | while ( text[idx] ) |
@@ -4003,7 +4006,7 @@ BOOL LLTextEditor::exportBuffer(LLString &buffer ) | |||
4003 | LLTextSegment::LLTextSegment(S32 start) : mStart(start) | 4006 | LLTextSegment::LLTextSegment(S32 start) : mStart(start) |
4004 | { | 4007 | { |
4005 | } | 4008 | } |
4006 | LLTextSegment::LLTextSegment( const LLStyle& style, S32 start, S32 end ) : | 4009 | LLTextSegment::LLTextSegment( const LLStyleSP& style, S32 start, S32 end ) : |
4007 | mStyle( style ), | 4010 | mStyle( style ), |
4008 | mStart( start), | 4011 | mStart( start), |
4009 | mEnd( end ), | 4012 | mEnd( end ), |
@@ -4011,9 +4014,8 @@ LLTextSegment::LLTextSegment( const LLStyle& style, S32 start, S32 end ) : | |||
4011 | mIsDefault(FALSE) | 4014 | mIsDefault(FALSE) |
4012 | { | 4015 | { |
4013 | } | 4016 | } |
4014 | LLTextSegment::LLTextSegment( | 4017 | LLTextSegment::LLTextSegment( const LLColor4& color, S32 start, S32 end, BOOL is_visible) : |
4015 | const LLColor4& color, S32 start, S32 end, BOOL is_visible) : | 4018 | mStyle(new LLStyle(is_visible,color,"")), |
4016 | mStyle( is_visible, color,"" ), | ||
4017 | mStart( start), | 4019 | mStart( start), |
4018 | mEnd( end ), | 4020 | mEnd( end ), |
4019 | mToken(NULL), | 4021 | mToken(NULL), |
@@ -4021,7 +4023,7 @@ LLTextSegment::LLTextSegment( | |||
4021 | { | 4023 | { |
4022 | } | 4024 | } |
4023 | LLTextSegment::LLTextSegment( const LLColor4& color, S32 start, S32 end ) : | 4025 | LLTextSegment::LLTextSegment( const LLColor4& color, S32 start, S32 end ) : |
4024 | mStyle( TRUE, color,"" ), | 4026 | mStyle(new LLStyle(TRUE, color,"" )), |
4025 | mStart( start), | 4027 | mStart( start), |
4026 | mEnd( end ), | 4028 | mEnd( end ), |
4027 | mToken(NULL), | 4029 | mToken(NULL), |
@@ -4029,7 +4031,7 @@ LLTextSegment::LLTextSegment( const LLColor4& color, S32 start, S32 end ) : | |||
4029 | { | 4031 | { |
4030 | } | 4032 | } |
4031 | LLTextSegment::LLTextSegment( const LLColor3& color, S32 start, S32 end ) : | 4033 | LLTextSegment::LLTextSegment( const LLColor3& color, S32 start, S32 end ) : |
4032 | mStyle( TRUE, color,"" ), | 4034 | mStyle(new LLStyle(TRUE, color,"" )), |
4033 | mStart( start), | 4035 | mStart( start), |
4034 | mEnd( end ), | 4036 | mEnd( end ), |
4035 | mToken(NULL), | 4037 | mToken(NULL), |