summaryrefslogtreecommitdiff
path: root/indra/newview/llviewertexteditor.cpp
diff options
context:
space:
mode:
authorRichard Nelson <richard@lindenlab.com>2009-08-24 20:04:52 +0000
committerRichard Nelson <richard@lindenlab.com>2009-08-24 20:04:52 +0000
commit138bf1132262c479dbbd5c95195db46b1efd065f (patch)
treebe2286f245865008b4ca6d738194133542822d65 /indra/newview/llviewertexteditor.cpp
parentc2619694fd2f94ad7da2d6e936494f4c16601212 (diff)
merge -r 130399-131510 skinning-21 -> viewer-2.0.0-3
DEV-11254 DEV-11254 DEV-2003: DEV-21567 DEV-37301 EXT-104 EXT-138 EXT-217 EXT-256 EXT-259 EXT-259 EXT-328 EXT-348 EXT-386 EXT-399 EXT-403 EXT-460 EXT-492 EXT-492 EXT-531 EXT-537 EXT-684 improved text editor (handles multiple fonts simultaneously as well as inline widgets)
Diffstat (limited to 'indra/newview/llviewertexteditor.cpp')
-rw-r--r--indra/newview/llviewertexteditor.cpp589
1 files changed, 215 insertions, 374 deletions
diff --git a/indra/newview/llviewertexteditor.cpp b/indra/newview/llviewertexteditor.cpp
index 9e0713b494..7565c86696 100644
--- a/indra/newview/llviewertexteditor.cpp
+++ b/indra/newview/llviewertexteditor.cpp
@@ -62,6 +62,7 @@
#include "llnotecard.h"
#include "llmemorystream.h"
#include "llmenugl.h"
+#include "llscrollcontainer.h"
#include "llavataractions.h"
#include "llappviewer.h" // for gPacificDaylightTime
@@ -108,6 +109,105 @@ public:
}
};
+//
+// class LLEmbeddedItemSegment
+//
+
+const S32 EMBEDDED_ITEM_LABEL_PADDING = 2;
+
+class LLEmbeddedItemSegment : public LLTextSegment
+{
+public:
+ LLEmbeddedItemSegment(S32 pos, LLUIImagePtr image, LLPointer<LLInventoryItem> inv_item, LLTextEditor& editor)
+ : LLTextSegment(pos, pos + 1),
+ mImage(image),
+ mLabel(utf8str_to_wstring(inv_item->getName())),
+ mItem(inv_item),
+ mEditor(editor),
+ mHasMouseHover(false)
+ {
+
+ mStyle = new LLStyle(LLStyle::Params().font(LLFontGL::getFontSansSerif()));
+ mToolTip = inv_item->getName() + '\n' + inv_item->getDescription();
+ }
+
+ /*virtual*/ S32 getWidth(S32 first_char, S32 num_chars) const
+ {
+ if (num_chars == 0)
+ {
+ return 0;
+ }
+ else
+ {
+ return EMBEDDED_ITEM_LABEL_PADDING + mImage->getWidth() + mStyle->getFont()->getWidth(mLabel.c_str());
+ }
+
+ }
+ //virtual S32 getOffset(S32 segment_local_x_coord, S32 start_offset, S32 num_chars, bool round) const;
+ //virtual void updateLayout(const class LLTextEditor& editor);
+
+ /*virtual*/ S32 getNumChars(S32 num_pixels, S32 segment_offset, S32 line_offset, S32 max_chars) const
+ {
+ return 1;
+ }
+ /*virtual*/ F32 draw(S32 start, S32 end, S32 selection_start, S32 selection_end, const LLRect& draw_rect)
+ {
+ LLRect image_rect = draw_rect;
+ image_rect.mRight = image_rect.mLeft + mImage->getWidth();
+ image_rect.mTop = image_rect.mBottom + mImage->getHeight();
+ mImage->draw(image_rect);
+
+ LLColor4 color;
+ if (mEditor.getReadOnly())
+ {
+ color = LLUIColorTable::instance().getColor("TextEmbeddedItemReadOnlyColor");
+ }
+ else
+ {
+ color = LLUIColorTable::instance().getColor("TextEmbeddedItemColor");
+ }
+
+ F32 right_x;
+ mStyle->getFont()->render(mLabel, 0, image_rect.mRight + EMBEDDED_ITEM_LABEL_PADDING, draw_rect.mBottom, color, LLFontGL::LEFT, LLFontGL::BOTTOM, mHasMouseHover ? LLFontGL::UNDERLINE : 0, LLFontGL::NO_SHADOW, mLabel.length(), S32_MAX, &right_x);
+ return right_x;
+ }
+
+ /*virtual*/ S32 getMaxHeight() const
+ {
+ return llmax(mImage->getHeight(), llceil(mStyle->getFont()->getLineHeight()));
+ }
+ /*virtual*/ bool canEdit() const { return false; }
+ //virtual void unlinkFromDocument(class LLTextEditor* editor);
+ //virtual void linkToDocument(class LLTextEditor* editor);
+
+ virtual void setHasMouseHover(bool hover)
+ {
+ mHasMouseHover = hover;
+ }
+ //virtual const LLColor4& getColor() const;
+ //virtual void setColor(const LLColor4 &color);
+ //virtual void setStyle(const LLStyleSP &style);
+ virtual BOOL getToolTip( std::string& msg ) const
+ {
+ msg = mToolTip;
+ return TRUE;
+ }
+
+ /*virtual*/ const LLStyleSP getStyle() const { return mStyle; }
+
+private:
+ LLUIImagePtr mImage;
+ LLWString mLabel;
+ LLStyleSP mStyle;
+ std::string mToolTip;
+ LLPointer<LLInventoryItem> mItem;
+ LLTextEditor& mEditor;
+ bool mHasMouseHover;
+
+};
+
+
+
////////////////////////////////////////////////////////////
// LLEmbeddedItems
//
@@ -130,13 +230,11 @@ public:
// return true if there are no embedded items.
bool empty();
- void bindEmbeddedChars(const LLFontGL* font) const;
- void unbindEmbeddedChars(const LLFontGL* font) const;
-
BOOL insertEmbeddedItem(LLInventoryItem* item, llwchar* value, bool is_new);
BOOL removeEmbeddedItem( llwchar ext_char );
BOOL hasEmbeddedItem(llwchar ext_char); // returns TRUE if /this/ editor has an entry for this item
+ LLUIImagePtr getItemImage(llwchar ext_char) const;
void getEmbeddedItemList( std::vector<LLPointer<LLInventoryItem> >& items );
void addItems(const std::vector<LLPointer<LLInventoryItem> >& items);
@@ -351,27 +449,13 @@ BOOL LLEmbeddedItems::hasEmbeddedItem(llwchar ext_char)
return FALSE;
}
-void LLEmbeddedItems::bindEmbeddedChars( const LLFontGL* font ) const
-{
- if( sEntries.empty() )
- {
- return;
- }
- for (std::set<llwchar>::const_iterator iter1 = mEmbeddedUsedChars.begin(); iter1 != mEmbeddedUsedChars.end(); ++iter1)
+LLUIImagePtr LLEmbeddedItems::getItemImage(llwchar ext_char) const
+{
+ LLInventoryItem* item = getEmbeddedItem(ext_char);
+ if (item)
{
- llwchar wch = *iter1;
- item_map_t::iterator iter2 = sEntries.find(wch);
- if (iter2 == sEntries.end())
- {
- continue;
- }
- LLInventoryItem* item = iter2->second.mItem;
- if (!item)
- {
- continue;
- }
- const char* img_name;
+ const char* img_name = "";
switch( item->getType() )
{
case LLAssetType::AT_TEXTURE:
@@ -428,27 +512,14 @@ void LLEmbeddedItems::bindEmbeddedChars( const LLFontGL* font ) const
case LLAssetType::AT_GESTURE: img_name = "inv_item_gesture.tga"; break;
//TODO need img_name
case LLAssetType::AT_FAVORITE: img_name = "inv_item_landmark.tga"; break;
- default: llassert(0); continue;
+ default: llassert(0);
}
- LLUIImagePtr image = LLUI::getUIImage(img_name);
-
- font->addEmbeddedChar( wch, image->getImage(), item->getName() );
+ return LLUI::getUIImage(img_name);
}
+ return LLUIImagePtr();
}
-void LLEmbeddedItems::unbindEmbeddedChars( const LLFontGL* font ) const
-{
- if( sEntries.empty() )
- {
- return;
- }
-
- for (std::set<llwchar>::const_iterator iter1 = mEmbeddedUsedChars.begin(); iter1 != mEmbeddedUsedChars.end(); ++iter1)
- {
- font->removeEmbeddedChar(*iter1);
- }
-}
void LLEmbeddedItems::addItems(const std::vector<LLPointer<LLInventoryItem> >& items)
{
@@ -613,30 +684,16 @@ BOOL LLViewerTextEditor::handleToolTip(S32 x, S32 y, std::string& msg, LLRect* s
}
const LLTextSegment* cur_segment = getSegmentAtLocalPos( x, y );
- if( cur_segment )
+ if( cur_segment && cur_segment->getToolTip( msg ) )
{
- BOOL has_tool_tip = FALSE;
- if( cur_segment->getStyle()->getIsEmbeddedItem() )
- {
- LLWString wtip;
- has_tool_tip = getEmbeddedItemToolTipAtPos(cur_segment->getStart(), wtip);
- msg = wstring_to_utf8str(wtip);
- }
- else
- {
- has_tool_tip = cur_segment->getToolTip( msg );
- }
- if( has_tool_tip )
- {
- // Just use a slop area around the cursor
- // Convert rect local to screen coordinates
- S32 SLOP = 8;
- localPointToScreen(
- x - SLOP, y - SLOP,
- &(sticky_rect_screen->mLeft), &(sticky_rect_screen->mBottom) );
- sticky_rect_screen->mRight = sticky_rect_screen->mLeft + 2 * SLOP;
- sticky_rect_screen->mTop = sticky_rect_screen->mBottom + 2 * SLOP;
- }
+ // Just use a slop area around the cursor
+ // Convert rect local to screen coordinates
+ S32 SLOP = 8;
+ localPointToScreen(
+ x - SLOP, y - SLOP,
+ &(sticky_rect_screen->mLeft), &(sticky_rect_screen->mBottom) );
+ sticky_rect_screen->mRight = sticky_rect_screen->mLeft + 2 * SLOP;
+ sticky_rect_screen->mTop = sticky_rect_screen->mBottom + 2 * SLOP;
}
return TRUE;
}
@@ -648,21 +705,8 @@ BOOL LLViewerTextEditor::handleMouseDown(S32 x, S32 y, MASK mask)
// Let scrollbar have first dibs
handled = LLView::childrenHandleMouseDown(x, y, mask) != NULL;
- // enable I Agree checkbox if the user scrolled through entire text
- BOOL was_scrolled_to_bottom = (mScrollbar->getDocPos() == mScrollbar->getDocPosMax());
- if (mOnScrollEndCallback && was_scrolled_to_bottom)
+ if( !handled)
{
- mOnScrollEndCallback(mOnScrollEndData);
- }
-
- if( !handled && mTakesNonScrollClicks)
- {
- if (!(mask & MASK_SHIFT))
- {
- deselect();
- }
-
- BOOL start_select = TRUE;
if( allowsEmbeddedItems() )
{
setCursorAtLocalPos( x, y, FALSE );
@@ -685,192 +729,55 @@ BOOL LLViewerTextEditor::handleMouseDown(S32 x, S32 y, MASK mask)
localPointToScreen(x, y, &screen_x, &screen_y );
LLToolDragAndDrop::getInstance()->setDragStart( screen_x, screen_y );
- start_select = FALSE;
- }
- else
- {
- mDragItem = NULL;
- }
- }
-
- if( start_select )
- {
- // If we're not scrolling (handled by child), then we're selecting
- if (mask & MASK_SHIFT)
- {
- S32 old_cursor_pos = mCursorPos;
- setCursorAtLocalPos( x, y, TRUE );
-
- if (hasSelection())
- {
- /* Mac-like behavior - extend selection towards the cursor
- if (mCursorPos < mSelectionStart
- && mCursorPos < mSelectionEnd)
- {
- // ...left of selection
- mSelectionStart = llmax(mSelectionStart, mSelectionEnd);
- mSelectionEnd = mCursorPos;
- }
- else if (mCursorPos > mSelectionStart
- && mCursorPos > mSelectionEnd)
- {
- // ...right of selection
- mSelectionStart = llmin(mSelectionStart, mSelectionEnd);
- mSelectionEnd = mCursorPos;
- }
- else
- {
- mSelectionEnd = mCursorPos;
- }
- */
- // Windows behavior
- mSelectionEnd = mCursorPos;
- }
- else
+ if (hasTabStop())
{
- mSelectionStart = old_cursor_pos;
- mSelectionEnd = mCursorPos;
+ setFocus( TRUE );
}
- // assume we're starting a drag select
- mIsSelecting = TRUE;
+ handled = TRUE;
}
else
{
- setCursorAtLocalPos( x, y, TRUE );
- startSelection();
+ mDragItem = NULL;
}
- gFocusMgr.setMouseCapture( this );
}
- handled = TRUE;
- }
-
- if (hasTabStop())
- {
- setFocus(TRUE);
- handled = TRUE;
+ if (!handled)
+ {
+ handled = LLTextEditor::handleMouseDown(x, y, mask);
+ }
}
- // Delay cursor flashing
- resetKeystrokeTimer();
-
return handled;
}
BOOL LLViewerTextEditor::handleHover(S32 x, S32 y, MASK mask)
{
- static LLUICachedControl<S32> scrollbar_size ("UIScrollbarSize", 0);
- BOOL handled = FALSE;
+ BOOL handled = LLTextEditor::handleHover(x, y, mask);
- if (!mDragItem)
+ if(hasMouseCapture() && mDragItem)
{
- // leave hover segment active during drag and drop
- mHoverSegment = NULL;
- }
- if(hasMouseCapture() )
- {
- if( mIsSelecting )
- {
- if (x != mLastSelectionX || y != mLastSelectionY)
- {
- mLastSelectionX = x;
- mLastSelectionY = y;
- }
+ S32 screen_x;
+ S32 screen_y;
+ localPointToScreen(x, y, &screen_x, &screen_y );
- if( y > getTextRect().mTop )
- {
- mScrollbar->setDocPos( mScrollbar->getDocPos() - 1 );
- }
- else
- if( y < getTextRect().mBottom )
- {
- mScrollbar->setDocPos( mScrollbar->getDocPos() + 1 );
- }
+ mScroller->autoScroll(x, y);
- setCursorAtLocalPos( x, y, TRUE );
- mSelectionEnd = mCursorPos;
-
- updateScrollFromCursor();
- getWindow()->setCursor(UI_CURSOR_IBEAM);
- }
- else if( mDragItem )
+ if( LLToolDragAndDrop::getInstance()->isOverThreshold( screen_x, screen_y ) )
{
- S32 screen_x;
- S32 screen_y;
- localPointToScreen(x, y, &screen_x, &screen_y );
- if( LLToolDragAndDrop::getInstance()->isOverThreshold( screen_x, screen_y ) )
- {
- LLToolDragAndDrop::getInstance()->beginDrag(
- LLAssetType::lookupDragAndDropType( mDragItem->getType() ),
- mDragItem->getUUID(),
- LLToolDragAndDrop::SOURCE_NOTECARD,
- mPreviewID, mObjectID);
+ LLToolDragAndDrop::getInstance()->beginDrag(
+ LLAssetType::lookupDragAndDropType( mDragItem->getType() ),
+ mDragItem->getUUID(),
+ LLToolDragAndDrop::SOURCE_NOTECARD,
+ mPreviewID, mObjectID);
- return LLToolDragAndDrop::getInstance()->handleHover( x, y, mask );
- }
- getWindow()->setCursor(UI_CURSOR_HAND);
+ return LLToolDragAndDrop::getInstance()->handleHover( x, y, mask );
}
-
- lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (active)" << llendl;
+ getWindow()->setCursor(UI_CURSOR_HAND);
handled = TRUE;
}
- if( !handled )
- {
- // Pass to children
- handled = LLView::childrenHandleHover(x, y, mask) != NULL;
- }
-
- if( handled )
- {
- // Delay cursor flashing
- resetKeystrokeTimer();
- }
-
- // Opaque
- if( !handled && mTakesNonScrollClicks)
- {
- // Check to see if we're over an HTML-style link
- if( !mSegments.empty() )
- {
- const LLTextSegment* cur_segment = getSegmentAtLocalPos( x, y );
- if( cur_segment )
- {
- if(cur_segment->getStyle()->isLink())
- {
- lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (over link, inactive)" << llendl;
- getWindow()->setCursor(UI_CURSOR_HAND);
- handled = TRUE;
- }
- else
- if(cur_segment->getStyle()->getIsEmbeddedItem())
- {
- lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (over embedded item, inactive)" << llendl;
- getWindow()->setCursor(UI_CURSOR_HAND);
- //getWindow()->setCursor(UI_CURSOR_ARROW);
- handled = TRUE;
- }
- mHoverSegment = cur_segment;
- }
- }
-
- if( !handled )
- {
- lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (inactive)" << llendl;
- if (!mScrollbar->getVisible() || x < getRect().getWidth() - scrollbar_size)
- {
- getWindow()->setCursor(UI_CURSOR_IBEAM);
- }
- else
- {
- getWindow()->setCursor(UI_CURSOR_ARROW);
- }
- handled = TRUE;
- }
- }
-
return handled;
}
@@ -903,13 +810,6 @@ BOOL LLViewerTextEditor::handleMouseUp(S32 x, S32 y, MASK mask)
handled = LLTextEditor::handleMouseUp(x,y,mask);
- // Used to enable I Agree checkbox if the user scrolled through entire text
- BOOL was_scrolled_to_bottom = (mScrollbar->getDocPos() == mScrollbar->getDocPosMax());
- if (mOnScrollEndCallback && was_scrolled_to_bottom)
- {
- mOnScrollEndCallback(mOnScrollEndData);
- }
-
return handled;
}
@@ -949,24 +849,6 @@ BOOL LLViewerTextEditor::handleRightMouseDown(S32 x, S32 y, MASK mask)
return handled;
}
-BOOL LLViewerTextEditor::handleMiddleMouseDown(S32 x, S32 y, MASK mask)
-{
- BOOL handled = FALSE;
- handled = childrenHandleMiddleMouseDown(x, y, mask) != NULL;
- if (!handled)
- {
- handled = LLTextEditor::handleMiddleMouseDown(x, y, mask);
- }
- return handled;
-}
-
-BOOL LLViewerTextEditor::handleMiddleMouseUp(S32 x, S32 y, MASK mask)
-{
- BOOL handled = childrenHandleMiddleMouseUp(x, y, mask) != NULL;
-
- return handled;
-}
-
BOOL LLViewerTextEditor::handleDoubleClick(S32 x, S32 y, MASK mask)
{
BOOL handled = FALSE;
@@ -974,14 +856,15 @@ BOOL LLViewerTextEditor::handleDoubleClick(S32 x, S32 y, MASK mask)
// let scrollbar have first dibs
handled = LLView::childrenHandleDoubleClick(x, y, mask) != NULL;
- if( !handled && mTakesNonScrollClicks)
+ if( !handled)
{
if( allowsEmbeddedItems() )
{
- const LLTextSegment* cur_segment = getSegmentAtLocalPos( x, y );
- if( cur_segment && cur_segment->getStyle()->getIsEmbeddedItem() )
+ S32 doc_index = getDocIndexFromLocalCoord(x, y, FALSE);
+ llwchar doc_char = getWText()[doc_index];
+ if (mEmbeddedItemList->hasEmbeddedItem(doc_char))
{
- if( openEmbeddedItemAtPos( cur_segment->getStart() ) )
+ if( openEmbeddedItemAtPos( doc_index ))
{
deselect();
setFocus( FALSE );
@@ -989,47 +872,7 @@ BOOL LLViewerTextEditor::handleDoubleClick(S32 x, S32 y, MASK mask)
}
}
}
-
- setCursorAtLocalPos( x, y, FALSE );
- deselect();
-
- const LLWString &text = getWText();
-
- if( isPartOfWord( text[mCursorPos] ) )
- {
- // Select word the cursor is over
- while ((mCursorPos > 0) && isPartOfWord(text[mCursorPos-1]))
- {
- mCursorPos--;
- }
- startSelection();
-
- while ((mCursorPos < (S32)text.length()) && isPartOfWord( text[mCursorPos] ) )
- {
- mCursorPos++;
- }
-
- mSelectionEnd = mCursorPos;
- }
- else if ((mCursorPos < (S32)text.length()) && !iswspace( text[mCursorPos]) )
- {
- // Select the character the cursor is over
- startSelection();
- mCursorPos++;
- mSelectionEnd = mCursorPos;
- }
-
- // We don't want handleMouseUp() to "finish" the selection (and thereby
- // set mSelectionEnd to where the mouse is), so we finish the selection here.
- mIsSelecting = FALSE;
-
- // delay cursor flashing
- resetKeystrokeTimer();
-
- // take selection to 'primary' clipboard
- updatePrimary();
-
- handled = TRUE;
+ handled = LLTextEditor::handleDoubleClick(x, y, mask);
}
return handled;
}
@@ -1051,80 +894,78 @@ BOOL LLViewerTextEditor::handleDragAndDrop(S32 x, S32 y, MASK mask,
return FALSE;
}
- if (mTakesNonScrollClicks)
+ if (getEnabled() && acceptsTextInput())
{
- if (getEnabled() && acceptsTextInput())
+ switch( cargo_type )
{
- switch( cargo_type )
+ case DAD_CALLINGCARD:
+ case DAD_TEXTURE:
+ case DAD_SOUND:
+ case DAD_LANDMARK:
+ case DAD_SCRIPT:
+ case DAD_CLOTHING:
+ case DAD_OBJECT:
+ case DAD_NOTECARD:
+ case DAD_BODYPART:
+ case DAD_ANIMATION:
+ case DAD_GESTURE:
{
- case DAD_CALLINGCARD:
- case DAD_TEXTURE:
- case DAD_SOUND:
- case DAD_LANDMARK:
- case DAD_SCRIPT:
- case DAD_CLOTHING:
- case DAD_OBJECT:
- case DAD_NOTECARD:
- case DAD_BODYPART:
- case DAD_ANIMATION:
- case DAD_GESTURE:
+ LLInventoryItem *item = (LLInventoryItem *)cargo_data;
+ if( item && allowsEmbeddedItems() )
{
- LLInventoryItem *item = (LLInventoryItem *)cargo_data;
- if( item && allowsEmbeddedItems() )
+ U32 mask_next = item->getPermissions().getMaskNextOwner();
+ if((mask_next & PERM_ITEM_UNRESTRICTED) == PERM_ITEM_UNRESTRICTED)
{
- U32 mask_next = item->getPermissions().getMaskNextOwner();
- if((mask_next & PERM_ITEM_UNRESTRICTED) == PERM_ITEM_UNRESTRICTED)
- {
- if( drop )
- {
- deselect();
- S32 old_cursor = mCursorPos;
- setCursorAtLocalPos( x, y, TRUE );
- S32 insert_pos = mCursorPos;
- setCursorPos(old_cursor);
- BOOL inserted = insertEmbeddedItem( insert_pos, item );
- if( inserted && (old_cursor > mCursorPos) )
- {
- setCursorPos(mCursorPos + 1);
- }
-
- updateLineStartList();
- }
- *accept = ACCEPT_YES_COPY_MULTI;
- }
- else
+ if( drop )
{
- *accept = ACCEPT_NO;
- if (tooltip_msg.empty())
+ deselect();
+ S32 old_cursor = mCursorPos;
+ setCursorAtLocalPos( x, y, TRUE );
+ S32 insert_pos = mCursorPos;
+ setCursorPos(old_cursor);
+ BOOL inserted = insertEmbeddedItem( insert_pos, item );
+ if( inserted && (old_cursor > mCursorPos) )
{
- // *TODO: Translate
- tooltip_msg.assign("Only items with unrestricted\n"
- "'next owner' permissions \n"
- "can be attached to notecards.");
+ setCursorPos(mCursorPos + 1);
}
+
+ needsReflow();
+
}
+ *accept = ACCEPT_YES_COPY_MULTI;
}
else
{
*accept = ACCEPT_NO;
+ if (tooltip_msg.empty())
+ {
+ // *TODO: Translate
+ tooltip_msg.assign("Only items with unrestricted\n"
+ "'next owner' permissions \n"
+ "can be attached to notecards.");
+ }
}
- break;
}
-
- default:
+ else
+ {
*accept = ACCEPT_NO;
- break;
+ }
+ break;
}
- }
- else
- {
- // Not enabled
+
+ default:
*accept = ACCEPT_NO;
+ break;
}
-
- handled = TRUE;
- lldebugst(LLERR_USER_INPUT) << "dragAndDrop handled by LLViewerTextEditor " << getName() << llendl;
}
+ else
+ {
+ // Not enabled
+ *accept = ACCEPT_NO;
+ }
+
+ handled = TRUE;
+ lldebugst(LLERR_USER_INPUT) << "dragAndDrop handled by LLViewerTextEditor " << getName() << llendl;
return handled;
}
@@ -1244,33 +1085,33 @@ llwchar LLViewerTextEditor::pasteEmbeddedItem(llwchar ext_char)
return LL_UNKNOWN_CHAR; // item not found or list full
}
-void LLViewerTextEditor::bindEmbeddedChars(const LLFontGL* font) const
+void LLViewerTextEditor::onValueChange(S32 start, S32 end)
{
- mEmbeddedItemList->bindEmbeddedChars( font );
+ updateSegments();
+ findEmbeddedItemSegments(start, end);
}
-void LLViewerTextEditor::unbindEmbeddedChars(const LLFontGL* font) const
+void LLViewerTextEditor::findEmbeddedItemSegments(S32 start, S32 end)
{
- mEmbeddedItemList->unbindEmbeddedChars( font );
-}
+ LLWString text = getWText();
-BOOL LLViewerTextEditor::getEmbeddedItemToolTipAtPos(S32 pos, LLWString &msg) const
-{
- if (pos < getLength())
+ LLColor4 text_color = ( mReadOnly ? mReadOnlyFgColor.get() : mFgColor.get() );
+
+ // Start with i just after the first embedded item
+ for(S32 idx = start; idx < end; idx++ )
{
- LLInventoryItem* item = LLEmbeddedItems::getEmbeddedItem(getWChar(pos));
- if( item )
+ llwchar embedded_char = text[idx];
+ if( embedded_char >= FIRST_EMBEDDED_CHAR
+ && embedded_char <= LAST_EMBEDDED_CHAR
+ && mEmbeddedItemList->hasEmbeddedItem(embedded_char) )
{
- msg = utf8str_to_wstring(item->getName());
- msg += '\n';
- msg += utf8str_to_wstring(item->getDescription());
- return TRUE;
+ LLInventoryItem* itemp = mEmbeddedItemList->getEmbeddedItem(embedded_char);
+ LLUIImagePtr image = mEmbeddedItemList->getItemImage(embedded_char);
+ insertSegment(new LLEmbeddedItemSegment(idx, image, itemp, *this));
}
}
- return FALSE;
}
-
BOOL LLViewerTextEditor::openEmbeddedItemAtPos(S32 pos)
{
if( pos < getLength())