aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llviewertexteditor.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:34 -0500
committerJacek Antonelli2008-08-15 23:45:34 -0500
commitcd17687f01420952712a500107e0f93e7ab8d5f8 (patch)
treece48c2b706f2c1176290e39fb555fbdf6648ce01 /linden/indra/newview/llviewertexteditor.cpp
parentSecond Life viewer sources 1.19.0.5 (diff)
downloadmeta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.zip
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.gz
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.bz2
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.xz
Second Life viewer sources 1.19.1.0
Diffstat (limited to 'linden/indra/newview/llviewertexteditor.cpp')
-rw-r--r--linden/indra/newview/llviewertexteditor.cpp246
1 files changed, 134 insertions, 112 deletions
diff --git a/linden/indra/newview/llviewertexteditor.cpp b/linden/indra/newview/llviewertexteditor.cpp
index fcc73b4..15085ac 100644
--- a/linden/indra/newview/llviewertexteditor.cpp
+++ b/linden/indra/newview/llviewertexteditor.cpp
@@ -1,6 +1,6 @@
1/** 1/**
2 * @file llviewertexteditor.cpp 2 * @file llviewertexteditor.cpp
3 * @brief Text editor widget to let users enter a a multi-line ASCII document. 3 * @brief Text editor widget to let users enter a multi-line document.
4 * 4 *
5 * $LicenseInfo:firstyear=2001&license=viewergpl$ 5 * $LicenseInfo:firstyear=2001&license=viewergpl$
6 * 6 *
@@ -145,8 +145,8 @@ public:
145 // return true if there are no embedded items. 145 // return true if there are no embedded items.
146 bool empty(); 146 bool empty();
147 147
148 void bindEmbeddedChars(const LLFontGL* font); 148 void bindEmbeddedChars(LLFontGL* font) const;
149 void unbindEmbeddedChars(const LLFontGL* font); 149 void unbindEmbeddedChars(LLFontGL* font) const;
150 150
151 BOOL insertEmbeddedItem(LLInventoryItem* item, llwchar* value, bool is_new); 151 BOOL insertEmbeddedItem(LLInventoryItem* item, llwchar* value, bool is_new);
152 BOOL removeEmbeddedItem( llwchar ext_char ); 152 BOOL removeEmbeddedItem( llwchar ext_char );
@@ -167,12 +167,13 @@ public:
167 static LLInventoryItem* getEmbeddedItem(llwchar ext_char); // returns item from static list 167 static LLInventoryItem* getEmbeddedItem(llwchar ext_char); // returns item from static list
168 static BOOL getEmbeddedItemSaved(llwchar ext_char); // returns whether item from static list is saved 168 static BOOL getEmbeddedItemSaved(llwchar ext_char); // returns whether item from static list is saved
169 169
170private:
171
170 struct embedded_info_t 172 struct embedded_info_t
171 { 173 {
172 LLPointer<LLInventoryItem> mItem; 174 LLPointer<LLInventoryItem> mItem;
173 BOOL mSaved; 175 BOOL mSaved;
174 }; 176 };
175private:
176 typedef std::map<llwchar, embedded_info_t > item_map_t; 177 typedef std::map<llwchar, embedded_info_t > item_map_t;
177 static item_map_t sEntries; 178 static item_map_t sEntries;
178 static std::stack<llwchar> sFreeEntries; 179 static std::stack<llwchar> sFreeEntries;
@@ -227,14 +228,14 @@ BOOL LLEmbeddedItems::insertEmbeddedItem( LLInventoryItem* item, llwchar* ext_ch
227 } 228 }
228 else if (sEntries.empty()) 229 else if (sEntries.empty())
229 { 230 {
230 wc_emb = FIRST_EMBEDDED_CHAR; 231 wc_emb = LLTextEditor::FIRST_EMBEDDED_CHAR;
231 } 232 }
232 else 233 else
233 { 234 {
234 item_map_t::iterator last = sEntries.end(); 235 item_map_t::iterator last = sEntries.end();
235 --last; 236 --last;
236 wc_emb = last->first; 237 wc_emb = last->first;
237 if (wc_emb >= LAST_EMBEDDED_CHAR) 238 if (wc_emb >= LLTextEditor::LAST_EMBEDDED_CHAR)
238 { 239 {
239 return FALSE; 240 return FALSE;
240 } 241 }
@@ -265,7 +266,7 @@ BOOL LLEmbeddedItems::removeEmbeddedItem( llwchar ext_char )
265// static 266// static
266LLInventoryItem* LLEmbeddedItems::getEmbeddedItem(llwchar ext_char) 267LLInventoryItem* LLEmbeddedItems::getEmbeddedItem(llwchar ext_char)
267{ 268{
268 if( ext_char >= FIRST_EMBEDDED_CHAR && ext_char <= LAST_EMBEDDED_CHAR ) 269 if( ext_char >= LLTextEditor::FIRST_EMBEDDED_CHAR && ext_char <= LLTextEditor::LAST_EMBEDDED_CHAR )
269 { 270 {
270 item_map_t::iterator iter = sEntries.find(ext_char); 271 item_map_t::iterator iter = sEntries.find(ext_char);
271 if (iter != sEntries.end()) 272 if (iter != sEntries.end())
@@ -279,7 +280,7 @@ LLInventoryItem* LLEmbeddedItems::getEmbeddedItem(llwchar ext_char)
279// static 280// static
280BOOL LLEmbeddedItems::getEmbeddedItemSaved(llwchar ext_char) 281BOOL LLEmbeddedItems::getEmbeddedItemSaved(llwchar ext_char)
281{ 282{
282 if( ext_char >= FIRST_EMBEDDED_CHAR && ext_char <= LAST_EMBEDDED_CHAR ) 283 if( ext_char >= LLTextEditor::FIRST_EMBEDDED_CHAR && ext_char <= LLTextEditor::LAST_EMBEDDED_CHAR )
283 { 284 {
284 item_map_t::iterator iter = sEntries.find(ext_char); 285 item_map_t::iterator iter = sEntries.find(ext_char);
285 if (iter != sEntries.end()) 286 if (iter != sEntries.end())
@@ -307,7 +308,7 @@ void LLEmbeddedItems::removeUnusedChars()
307 for (S32 i=0; i<(S32)wtext.size(); i++) 308 for (S32 i=0; i<(S32)wtext.size(); i++)
308 { 309 {
309 llwchar wc = wtext[i]; 310 llwchar wc = wtext[i];
310 if( wc >= FIRST_EMBEDDED_CHAR && wc <= LAST_EMBEDDED_CHAR ) 311 if( wc >= LLTextEditor::FIRST_EMBEDDED_CHAR && wc <= LLTextEditor::LAST_EMBEDDED_CHAR )
311 { 312 {
312 used.erase(wc); 313 used.erase(wc);
313 } 314 }
@@ -365,14 +366,14 @@ BOOL LLEmbeddedItems::hasEmbeddedItem(llwchar ext_char)
365 return FALSE; 366 return FALSE;
366} 367}
367 368
368void LLEmbeddedItems::bindEmbeddedChars( const LLFontGL* font ) 369void LLEmbeddedItems::bindEmbeddedChars( LLFontGL* font ) const
369{ 370{
370 if( sEntries.empty() ) 371 if( sEntries.empty() )
371 { 372 {
372 return; 373 return;
373 } 374 }
374 375
375 for (std::set<llwchar>::iterator iter1 = mEmbeddedUsedChars.begin(); iter1 != mEmbeddedUsedChars.end(); ++iter1) 376 for (std::set<llwchar>::const_iterator iter1 = mEmbeddedUsedChars.begin(); iter1 != mEmbeddedUsedChars.end(); ++iter1)
376 { 377 {
377 llwchar wch = *iter1; 378 llwchar wch = *iter1;
378 item_map_t::iterator iter2 = sEntries.find(wch); 379 item_map_t::iterator iter2 = sEntries.find(wch);
@@ -431,20 +432,20 @@ void LLEmbeddedItems::bindEmbeddedChars( const LLFontGL* font )
431 432
432 LLViewerImage* image = gImageList.getImage(LLUUID(gViewerArt.getString(img_name)), MIPMAP_FALSE, TRUE); 433 LLViewerImage* image = gImageList.getImage(LLUUID(gViewerArt.getString(img_name)), MIPMAP_FALSE, TRUE);
433 434
434 ((LLFontGL*)font)->addEmbeddedChar( wch, image, item->getName() ); 435 font->addEmbeddedChar( wch, image, item->getName() );
435 } 436 }
436} 437}
437 438
438void LLEmbeddedItems::unbindEmbeddedChars( const LLFontGL* font ) 439void LLEmbeddedItems::unbindEmbeddedChars( LLFontGL* font ) const
439{ 440{
440 if( sEntries.empty() ) 441 if( sEntries.empty() )
441 { 442 {
442 return; 443 return;
443 } 444 }
444 445
445 for (std::set<llwchar>::iterator iter1 = mEmbeddedUsedChars.begin(); iter1 != mEmbeddedUsedChars.end(); ++iter1) 446 for (std::set<llwchar>::const_iterator iter1 = mEmbeddedUsedChars.begin(); iter1 != mEmbeddedUsedChars.end(); ++iter1)
446 { 447 {
447 ((LLFontGL*)font)->removeEmbeddedChar(*iter1); 448 font->removeEmbeddedChar(*iter1);
448 } 449 }
449} 450}
450 451
@@ -490,7 +491,7 @@ void LLEmbeddedItems::markSaved()
490 491
491/////////////////////////////////////////////////////////////////// 492///////////////////////////////////////////////////////////////////
492 493
493class LLTextCmdInsertEmbeddedItem : public LLTextCmd 494class LLViewerTextEditor::LLTextCmdInsertEmbeddedItem : public LLTextEditor::LLTextCmd
494{ 495{
495public: 496public:
496 LLTextCmdInsertEmbeddedItem( S32 pos, LLInventoryItem* item ) 497 LLTextCmdInsertEmbeddedItem( S32 pos, LLInventoryItem* item )
@@ -509,7 +510,7 @@ public:
509 { 510 {
510 LLWString ws; 511 LLWString ws;
511 ws.assign(1, mExtCharValue); 512 ws.assign(1, mExtCharValue);
512 *delta = insert(editor, mPos, ws ); 513 *delta = insert(editor, getPosition(), ws );
513 return (*delta != 0); 514 return (*delta != 0);
514 } 515 }
515 return FALSE; 516 return FALSE;
@@ -517,18 +518,18 @@ public:
517 518
518 virtual S32 undo( LLTextEditor* editor ) 519 virtual S32 undo( LLTextEditor* editor )
519 { 520 {
520 remove(editor, mPos, 1); 521 remove(editor, getPosition(), 1);
521 return mPos; 522 return getPosition();
522 } 523 }
523 524
524 virtual S32 redo( LLTextEditor* editor ) 525 virtual S32 redo( LLTextEditor* editor )
525 { 526 {
526 LLWString ws; 527 LLWString ws;
527 ws += mExtCharValue; 528 ws += mExtCharValue;
528 insert(editor, mPos, ws ); 529 insert(editor, getPosition(), ws );
529 return mPos + 1; 530 return getPosition() + 1;
530 } 531 }
531 virtual BOOL hasExtCharValue( llwchar value ) 532 virtual BOOL hasExtCharValue( llwchar value ) const
532 { 533 {
533 return (value == mExtCharValue); 534 return (value == mExtCharValue);
534 } 535 }
@@ -571,17 +572,17 @@ LLViewerTextEditor::LLViewerTextEditor(const LLString& name,
571 mEmbeddedItemList = new LLEmbeddedItems(this); 572 mEmbeddedItemList = new LLEmbeddedItems(this);
572 mInventoryCallback->setEditor(this); 573 mInventoryCallback->setEditor(this);
573 574
575 // *TODO: Add right click menus for SLURLs
574 // Build the right click menu 576 // Build the right click menu
575 // make the popup menu available 577 // make the popup menu available
576 578 //LLMenuGL* menu = gUICtrlFactory->buildMenu("menu_slurl.xml", this);
577 LLMenuGL* menu = gUICtrlFactory->buildMenu("menu_slurl.xml", this); 579 //if (!menu)
578 if (!menu) 580 //{
579 { 581 // menu = new LLMenuGL("");
580 menu = new LLMenuGL(""); 582 //}
581 } 583 //menu->setBackgroundColor(gColors.getColor("MenuPopupBgColor"));
582 menu->setBackgroundColor(gColors.getColor("MenuPopupBgColor")); 584 //// menu->setVisible(FALSE);
583 // menu->setVisible(FALSE); 585 //mPopupMenuHandle = menu->getHandle();
584 mPopupMenuHandle = menu->mViewHandle;
585} 586}
586 587
587LLViewerTextEditor::~LLViewerTextEditor() 588LLViewerTextEditor::~LLViewerTextEditor()
@@ -623,7 +624,7 @@ BOOL LLViewerTextEditor::handleToolTip(S32 x, S32 y, LLString& msg, LLRect* stic
623 return TRUE; 624 return TRUE;
624 } 625 }
625 626
626 LLTextSegment* cur_segment = getSegmentAtLocalPos( x, y ); 627 const LLTextSegment* cur_segment = getSegmentAtLocalPos( x, y );
627 if( cur_segment ) 628 if( cur_segment )
628 { 629 {
629 BOOL has_tool_tip = FALSE; 630 BOOL has_tool_tip = FALSE;
@@ -674,13 +675,13 @@ BOOL LLViewerTextEditor::handleMouseDown(S32 x, S32 y, MASK mask)
674 } 675 }
675 676
676 BOOL start_select = TRUE; 677 BOOL start_select = TRUE;
677 if( mAllowEmbeddedItems ) 678 if( allowsEmbeddedItems() )
678 { 679 {
679 setCursorAtLocalPos( x, y, FALSE ); 680 setCursorAtLocalPos( x, y, FALSE );
680 llwchar wc = 0; 681 llwchar wc = 0;
681 if (mCursorPos < getLength()) 682 if (mCursorPos < getLength())
682 { 683 {
683 wc = mWText[mCursorPos]; 684 wc = getWChar(mCursorPos);
684 } 685 }
685 LLInventoryItem* item_at_pos = LLEmbeddedItems::getEmbeddedItem(wc); 686 LLInventoryItem* item_at_pos = LLEmbeddedItems::getEmbeddedItem(wc);
686 if (item_at_pos) 687 if (item_at_pos)
@@ -763,7 +764,7 @@ BOOL LLViewerTextEditor::handleMouseDown(S32 x, S32 y, MASK mask)
763 } 764 }
764 765
765 // Delay cursor flashing 766 // Delay cursor flashing
766 mKeystrokeTimer.reset(); 767 resetKeystrokeTimer();
767 768
768 return handled; 769 return handled;
769} 770}
@@ -790,12 +791,12 @@ BOOL LLViewerTextEditor::handleHover(S32 x, S32 y, MASK mask)
790 mLastSelectionY = y; 791 mLastSelectionY = y;
791 } 792 }
792 793
793 if( y > mTextRect.mTop ) 794 if( y > getTextRect().mTop )
794 { 795 {
795 mScrollbar->setDocPos( mScrollbar->getDocPos() - 1 ); 796 mScrollbar->setDocPos( mScrollbar->getDocPos() - 1 );
796 } 797 }
797 else 798 else
798 if( y < mTextRect.mBottom ) 799 if( y < getTextRect().mBottom )
799 { 800 {
800 mScrollbar->setDocPos( mScrollbar->getDocPos() + 1 ); 801 mScrollbar->setDocPos( mScrollbar->getDocPos() + 1 );
801 } 802 }
@@ -817,7 +818,7 @@ BOOL LLViewerTextEditor::handleHover(S32 x, S32 y, MASK mask)
817 LLAssetType::lookupDragAndDropType( mDragItem->getType() ), 818 LLAssetType::lookupDragAndDropType( mDragItem->getType() ),
818 mDragItem->getUUID(), 819 mDragItem->getUUID(),
819 LLToolDragAndDrop::SOURCE_NOTECARD, 820 LLToolDragAndDrop::SOURCE_NOTECARD,
820 mSourceID, mObjectID); 821 getSourceID(), mObjectID);
821 822
822 return gToolDragAndDrop->handleHover( x, y, mask ); 823 return gToolDragAndDrop->handleHover( x, y, mask );
823 } 824 }
@@ -837,7 +838,7 @@ BOOL LLViewerTextEditor::handleHover(S32 x, S32 y, MASK mask)
837 if( handled ) 838 if( handled )
838 { 839 {
839 // Delay cursor flashing 840 // Delay cursor flashing
840 mKeystrokeTimer.reset(); 841 resetKeystrokeTimer();
841 } 842 }
842 843
843 // Opaque 844 // Opaque
@@ -846,7 +847,7 @@ BOOL LLViewerTextEditor::handleHover(S32 x, S32 y, MASK mask)
846 // Check to see if we're over an HTML-style link 847 // Check to see if we're over an HTML-style link
847 if( !mSegments.empty() ) 848 if( !mSegments.empty() )
848 { 849 {
849 LLTextSegment* cur_segment = getSegmentAtLocalPos( x, y ); 850 const LLTextSegment* cur_segment = getSegmentAtLocalPos( x, y );
850 if( cur_segment ) 851 if( cur_segment )
851 { 852 {
852 if(cur_segment->getStyle().isLink()) 853 if(cur_segment->getStyle().isLink())
@@ -870,7 +871,7 @@ BOOL LLViewerTextEditor::handleHover(S32 x, S32 y, MASK mask)
870 if( !handled ) 871 if( !handled )
871 { 872 {
872 lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (inactive)" << llendl; 873 lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (inactive)" << llendl;
873 if (!mScrollbar->getVisible() || x < mRect.getWidth() - SCROLLBAR_SIZE) 874 if (!mScrollbar->getVisible() || x < getRect().getWidth() - SCROLLBAR_SIZE)
874 { 875 {
875 getWindow()->setCursor(UI_CURSOR_IBEAM); 876 getWindow()->setCursor(UI_CURSOR_IBEAM);
876 } 877 }
@@ -894,7 +895,7 @@ BOOL LLViewerTextEditor::handleMouseUp(S32 x, S32 y, MASK mask)
894 // let scrollbar have first dibs 895 // let scrollbar have first dibs
895 handled = LLView::childrenHandleMouseUp(x, y, mask) != NULL; 896 handled = LLView::childrenHandleMouseUp(x, y, mask) != NULL;
896 897
897 // enable I Agree checkbox if the user scrolled through entire text 898 // Used to enable I Agree checkbox if the user scrolled through entire text
898 BOOL was_scrolled_to_bottom = (mScrollbar->getDocPos() == mScrollbar->getDocPosMax()); 899 BOOL was_scrolled_to_bottom = (mScrollbar->getDocPos() == mScrollbar->getDocPosMax());
899 if (mOnScrollEndCallback && was_scrolled_to_bottom) 900 if (mOnScrollEndCallback && was_scrolled_to_bottom)
900 { 901 {
@@ -906,12 +907,12 @@ BOOL LLViewerTextEditor::handleMouseUp(S32 x, S32 y, MASK mask)
906 if( mIsSelecting ) 907 if( mIsSelecting )
907 { 908 {
908 // Finish selection 909 // Finish selection
909 if( y > mTextRect.mTop ) 910 if( y > getTextRect().mTop )
910 { 911 {
911 mScrollbar->setDocPos( mScrollbar->getDocPos() - 1 ); 912 mScrollbar->setDocPos( mScrollbar->getDocPos() - 1 );
912 } 913 }
913 else 914 else
914 if( y < mTextRect.mBottom ) 915 if( y < getTextRect().mBottom )
915 { 916 {
916 mScrollbar->setDocPos( mScrollbar->getDocPos() + 1 ); 917 mScrollbar->setDocPos( mScrollbar->getDocPos() + 1 );
917 } 918 }
@@ -931,7 +932,7 @@ BOOL LLViewerTextEditor::handleMouseUp(S32 x, S32 y, MASK mask)
931 } 932 }
932 933
933 // Delay cursor flashing 934 // Delay cursor flashing
934 mKeystrokeTimer.reset(); 935 resetKeystrokeTimer();
935 936
936 if( hasMouseCapture() ) 937 if( hasMouseCapture() )
937 { 938 {
@@ -942,7 +943,13 @@ BOOL LLViewerTextEditor::handleMouseUp(S32 x, S32 y, MASK mask)
942 S32 dy = y - mMouseDownY; 943 S32 dy = y - mMouseDownY;
943 if (-2 < dx && dx < 2 && -2 < dy && dy < 2) 944 if (-2 < dx && dx < 2 && -2 < dy && dy < 2)
944 { 945 {
945 openEmbeddedItem(mDragItem, mDragItemSaved); 946 if(mDragItemSaved)
947 {
948 openEmbeddedItem(mDragItem);
949 }else
950 {
951 showUnsavedAlertDialog(mDragItem);
952 }
946 } 953 }
947 } 954 }
948 mDragItem = NULL; 955 mDragItem = NULL;
@@ -959,34 +966,35 @@ BOOL LLViewerTextEditor::handleRightMouseDown(S32 x, S32 y, MASK mask)
959 966
960 BOOL handled = childrenHandleRightMouseDown(x, y, mask) != NULL; 967 BOOL handled = childrenHandleRightMouseDown(x, y, mask) != NULL;
961 968
962 if(! handled) 969 // *TODO: Add right click menus for SLURLs
963 { 970// if(! handled)
964 LLTextSegment* cur_segment = getSegmentAtLocalPos( x, y ); 971// {
965 if( cur_segment ) 972// const LLTextSegment* cur_segment = getSegmentAtLocalPos( x, y );
966 { 973// if( cur_segment )
967 if(cur_segment->getStyle().isLink()) 974// {
968 { 975// if(cur_segment->getStyle().isLink())
969 handled = TRUE; 976// {
970 mHTML = cur_segment->getStyle().getLinkHREF(); 977// handled = TRUE;
971 } 978// mHTML = cur_segment->getStyle().getLinkHREF();
972 } 979// }
973 } 980// }
974 LLMenuGL* menu = (LLMenuGL*)LLView::getViewByHandle(mPopupMenuHandle); 981// }
975 if(handled && menu && mParseHTML && mHTML.length() > 0) 982// LLMenuGL* menu = (LLMenuGL*)mPopupMenuHandle.get();
976 { 983// if(handled && menu && mParseHTML && mHTML.length() > 0)
977 menu->setVisible(TRUE); 984// {
978 menu->arrange(); 985// menu->setVisible(TRUE);
979 menu->updateParent(LLMenuGL::sMenuContainer); 986// menu->arrange();
980 LLMenuGL::showPopup(this, menu, x, y); 987// menu->updateParent(LLMenuGL::sMenuContainer);
981 mHTML = ""; 988// LLMenuGL::showPopup(this, menu, x, y);
982 } 989// mHTML = "";
983 else 990// }
984 { 991// else
985 if(menu && menu->getVisible()) 992// {
986 { 993// if(menu && menu->getVisible())
987 menu->setVisible(FALSE); 994// {
988 } 995// menu->setVisible(FALSE);
989 } 996// }
997// }
990 return handled; 998 return handled;
991} 999}
992 1000
@@ -999,9 +1007,9 @@ BOOL LLViewerTextEditor::handleDoubleClick(S32 x, S32 y, MASK mask)
999 1007
1000 if( !handled && mTakesNonScrollClicks) 1008 if( !handled && mTakesNonScrollClicks)
1001 { 1009 {
1002 if( mAllowEmbeddedItems ) 1010 if( allowsEmbeddedItems() )
1003 { 1011 {
1004 LLTextSegment* cur_segment = getSegmentAtLocalPos( x, y ); 1012 const LLTextSegment* cur_segment = getSegmentAtLocalPos( x, y );
1005 if( cur_segment && cur_segment->getStyle().getIsEmbeddedItem() ) 1013 if( cur_segment && cur_segment->getStyle().getIsEmbeddedItem() )
1006 { 1014 {
1007 if( openEmbeddedItemAtPos( cur_segment->getStart() ) ) 1015 if( openEmbeddedItemAtPos( cur_segment->getStart() ) )
@@ -1048,7 +1056,7 @@ BOOL LLViewerTextEditor::handleDoubleClick(S32 x, S32 y, MASK mask)
1048 mIsSelecting = FALSE; 1056 mIsSelecting = FALSE;
1049 1057
1050 // delay cursor flashing 1058 // delay cursor flashing
1051 mKeystrokeTimer.reset(); 1059 resetKeystrokeTimer();
1052 1060
1053 handled = TRUE; 1061 handled = TRUE;
1054 } 1062 }
@@ -1068,12 +1076,12 @@ BOOL LLViewerTextEditor::handleDragAndDrop(S32 x, S32 y, MASK mask,
1068 1076
1069 if (mTakesNonScrollClicks) 1077 if (mTakesNonScrollClicks)
1070 { 1078 {
1071 if (getEnabled() && !mReadOnly) 1079 if (getEnabled() && acceptsTextInput())
1072 { 1080 {
1073 switch( cargo_type ) 1081 switch( cargo_type )
1074 { 1082 {
1075 case DAD_CALLINGCARD: 1083 case DAD_CALLINGCARD:
1076 if(mAcceptCallingCardNames) 1084 if(acceptsCallingCardNames())
1077 { 1085 {
1078 if (drop) 1086 if (drop)
1079 { 1087 {
@@ -1101,7 +1109,7 @@ BOOL LLViewerTextEditor::handleDragAndDrop(S32 x, S32 y, MASK mask,
1101 case DAD_GESTURE: 1109 case DAD_GESTURE:
1102 { 1110 {
1103 LLInventoryItem *item = (LLInventoryItem *)cargo_data; 1111 LLInventoryItem *item = (LLInventoryItem *)cargo_data;
1104 if( mAllowEmbeddedItems ) 1112 if( allowsEmbeddedItems() )
1105 { 1113 {
1106 U32 mask_next = item->getPermissions().getMaskNextOwner(); 1114 U32 mask_next = item->getPermissions().getMaskNextOwner();
1107 if((mask_next & PERM_ITEM_UNRESTRICTED) == PERM_ITEM_UNRESTRICTED) 1115 if((mask_next & PERM_ITEM_UNRESTRICTED) == PERM_ITEM_UNRESTRICTED)
@@ -1202,9 +1210,9 @@ LLString LLViewerTextEditor::getEmbeddedText()
1202 // New version (Version 2) 1210 // New version (Version 2)
1203 mEmbeddedItemList->copyUsedCharsToIndexed(); 1211 mEmbeddedItemList->copyUsedCharsToIndexed();
1204 LLWString outtextw; 1212 LLWString outtextw;
1205 for (S32 i=0; i<(S32)mWText.size(); i++) 1213 for (S32 i=0; i<(S32)getWText().size(); i++)
1206 { 1214 {
1207 llwchar wch = mWText[i]; 1215 llwchar wch = getWChar(i);
1208 if( wch >= FIRST_EMBEDDED_CHAR && wch <= LAST_EMBEDDED_CHAR ) 1216 if( wch >= FIRST_EMBEDDED_CHAR && wch <= LAST_EMBEDDED_CHAR )
1209 { 1217 {
1210 S32 index = mEmbeddedItemList->getIndexFromEmbeddedChar(wch); 1218 S32 index = mEmbeddedItemList->getIndexFromEmbeddedChar(wch);
@@ -1276,21 +1284,21 @@ llwchar LLViewerTextEditor::pasteEmbeddedItem(llwchar ext_char)
1276 return LL_UNKNOWN_CHAR; // item not found or list full 1284 return LL_UNKNOWN_CHAR; // item not found or list full
1277} 1285}
1278 1286
1279void LLViewerTextEditor::bindEmbeddedChars(const LLFontGL* font) 1287void LLViewerTextEditor::bindEmbeddedChars(LLFontGL* font) const
1280{ 1288{
1281 mEmbeddedItemList->bindEmbeddedChars( font ); 1289 mEmbeddedItemList->bindEmbeddedChars( font );
1282} 1290}
1283 1291
1284void LLViewerTextEditor::unbindEmbeddedChars(const LLFontGL* font) 1292void LLViewerTextEditor::unbindEmbeddedChars(LLFontGL* font) const
1285{ 1293{
1286 mEmbeddedItemList->unbindEmbeddedChars( font ); 1294 mEmbeddedItemList->unbindEmbeddedChars( font );
1287} 1295}
1288 1296
1289BOOL LLViewerTextEditor::getEmbeddedItemToolTipAtPos(S32 pos, LLWString &msg) 1297BOOL LLViewerTextEditor::getEmbeddedItemToolTipAtPos(S32 pos, LLWString &msg) const
1290{ 1298{
1291 if (pos < getLength()) 1299 if (pos < getLength())
1292 { 1300 {
1293 LLInventoryItem* item = LLEmbeddedItems::getEmbeddedItem(mWText[pos]); 1301 LLInventoryItem* item = LLEmbeddedItems::getEmbeddedItem(getWChar(pos));
1294 if( item ) 1302 if( item )
1295 { 1303 {
1296 msg = utf8str_to_wstring(item->getName()); 1304 msg = utf8str_to_wstring(item->getName());
@@ -1307,19 +1315,27 @@ BOOL LLViewerTextEditor::openEmbeddedItemAtPos(S32 pos)
1307{ 1315{
1308 if( pos < getLength()) 1316 if( pos < getLength())
1309 { 1317 {
1310 LLInventoryItem* item = LLEmbeddedItems::getEmbeddedItem( mWText[pos] ); 1318 LLInventoryItem* item = LLEmbeddedItems::getEmbeddedItem( getWChar(pos) );
1311 if( item ) 1319 if( item )
1312 { 1320 {
1313 BOOL saved = LLEmbeddedItems::getEmbeddedItemSaved( mWText[pos] ); 1321 BOOL saved = LLEmbeddedItems::getEmbeddedItemSaved( getWChar(pos) );
1314 return openEmbeddedItem(item, saved); 1322 if (saved)
1323 {
1324 return openEmbeddedItem(item);
1325 }
1326 else
1327 {
1328 showUnsavedAlertDialog(item);
1329 }
1315 } 1330 }
1316 } 1331 }
1317 return FALSE; 1332 return FALSE;
1318} 1333}
1319 1334
1320 1335
1321BOOL LLViewerTextEditor::openEmbeddedItem(LLInventoryItem* item, BOOL saved) 1336BOOL LLViewerTextEditor::openEmbeddedItem(LLInventoryItem* item)
1322{ 1337{
1338
1323 switch( item->getType() ) 1339 switch( item->getType() )
1324 { 1340 {
1325 case LLAssetType::AT_TEXTURE: 1341 case LLAssetType::AT_TEXTURE:
@@ -1329,15 +1345,15 @@ BOOL LLViewerTextEditor::openEmbeddedItem(LLInventoryItem* item, BOOL saved)
1329 case LLAssetType::AT_SOUND: 1345 case LLAssetType::AT_SOUND:
1330 openEmbeddedSound( item ); 1346 openEmbeddedSound( item );
1331 return TRUE; 1347 return TRUE;
1332 1348
1333 case LLAssetType::AT_NOTECARD: 1349 case LLAssetType::AT_NOTECARD:
1334 openEmbeddedNotecard( item, saved ); 1350 openEmbeddedNotecard( item );
1335 return TRUE; 1351 return TRUE;
1336 1352
1337 case LLAssetType::AT_LANDMARK: 1353 case LLAssetType::AT_LANDMARK:
1338 openEmbeddedLandmark( item ); 1354 openEmbeddedLandmark( item );
1339 return TRUE; 1355 return TRUE;
1340 1356
1341 case LLAssetType::AT_LSL_TEXT: 1357 case LLAssetType::AT_LSL_TEXT:
1342 case LLAssetType::AT_CLOTHING: 1358 case LLAssetType::AT_CLOTHING:
1343 case LLAssetType::AT_OBJECT: 1359 case LLAssetType::AT_OBJECT:
@@ -1345,10 +1361,11 @@ BOOL LLViewerTextEditor::openEmbeddedItem(LLInventoryItem* item, BOOL saved)
1345 case LLAssetType::AT_ANIMATION: 1361 case LLAssetType::AT_ANIMATION:
1346 case LLAssetType::AT_GESTURE: 1362 case LLAssetType::AT_GESTURE:
1347 showCopyToInvDialog( item ); 1363 showCopyToInvDialog( item );
1348 return TRUE; 1364 return TRUE;
1349 default: 1365 default:
1350 return FALSE; 1366 return FALSE;
1351 } 1367 }
1368
1352} 1369}
1353 1370
1354 1371
@@ -1401,23 +1418,30 @@ void LLViewerTextEditor::openEmbeddedLandmark( LLInventoryItem* item )
1401 open_landmark((LLViewerInventoryItem*)item, title, FALSE, item->getUUID(), TRUE); 1418 open_landmark((LLViewerInventoryItem*)item, title, FALSE, item->getUUID(), TRUE);
1402} 1419}
1403 1420
1404void LLViewerTextEditor::openEmbeddedNotecard( LLInventoryItem* item, BOOL saved ) 1421void LLViewerTextEditor::openEmbeddedNotecard( LLInventoryItem* item )
1405{ 1422{
1406 if (saved) 1423 //if (saved)
1407 { 1424 //{
1408 // An LLInventoryItem needs to be in an inventory to be opened. 1425 // An LLInventoryItem needs to be in an inventory to be opened.
1409 // This will give the item to the viewer's agent. 1426 // This will give the item to the viewer's agent.
1410 // The callback will attempt to open it if its not already opened. 1427 // The callback will attempt to open it if its not already opened.
1411 copyInventory(item, gInventoryCallbacks.registerCB(mInventoryCallback)); 1428 copyInventory(item, gInventoryCallbacks.registerCB(mInventoryCallback));
1412 } 1429
1413 else 1430 //}
1414 { 1431 //else
1415 LLNotecardCopyInfo *info = new LLNotecardCopyInfo(this, item); 1432 //{
1416 gViewerWindow->alertXml("ConfirmNotecardSave", 1433 // LLNotecardCopyInfo *info = new LLNotecardCopyInfo(this, item);
1417 LLViewerTextEditor::onNotecardDialog, (void*)info); 1434 // gViewerWindow->alertXml("ConfirmNotecardSave",
1418 } 1435 // LLViewerTextEditor::onNotecardDialog, (void*)info);
1436 //}
1419} 1437}
1420 1438
1439void LLViewerTextEditor::showUnsavedAlertDialog( LLInventoryItem* item )
1440{
1441 LLNotecardCopyInfo *info = new LLNotecardCopyInfo(this, item);
1442 gViewerWindow->alertXml( "ConfirmNotecardSave",
1443 LLViewerTextEditor::onNotecardDialog, (void*)info);
1444}
1421// static 1445// static
1422void LLViewerTextEditor::onNotecardDialog( S32 option, void* userdata ) 1446void LLViewerTextEditor::onNotecardDialog( S32 option, void* userdata )
1423{ 1447{
@@ -1468,7 +1492,7 @@ bool LLViewerTextEditor::importStream(std::istream& str)
1468 const std::vector<LLPointer<LLInventoryItem> >& items = nc.getItems(); 1492 const std::vector<LLPointer<LLInventoryItem> >& items = nc.getItems();
1469 mEmbeddedItemList->addItems(items); 1493 mEmbeddedItemList->addItems(items);
1470 // Actually set the text 1494 // Actually set the text
1471 if (mAllowEmbeddedItems) 1495 if (allowsEmbeddedItems())
1472 { 1496 {
1473 if (nc.getVersion() == 1) 1497 if (nc.getVersion() == 1)
1474 setASCIIEmbeddedText( nc.getText() ); 1498 setASCIIEmbeddedText( nc.getText() );
@@ -1492,7 +1516,7 @@ void LLViewerTextEditor::copyInventory(const LLInventoryItem* item, U32 callback
1492 1516
1493bool LLViewerTextEditor::hasEmbeddedInventory() 1517bool LLViewerTextEditor::hasEmbeddedInventory()
1494{ 1518{
1495 return (!(mEmbeddedItemList->empty())); 1519 return ! mEmbeddedItemList->empty();
1496} 1520}
1497 1521
1498//////////////////////////////////////////////////////////////////////////// 1522////////////////////////////////////////////////////////////////////////////
@@ -1555,11 +1579,9 @@ LLView* LLViewerTextEditor::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlF
1555 font, 1579 font,
1556 allow_embedded_items); 1580 allow_embedded_items);
1557 1581
1558 BOOL ignore_tabs = text_editor->mTabToNextField; 1582 BOOL ignore_tabs = text_editor->tabsToNextField();
1559 node->getAttributeBOOL("ignore_tab", ignore_tabs); 1583 node->getAttributeBOOL("ignore_tab", ignore_tabs);
1560 1584 text_editor->setTabsToNextField(ignore_tabs);
1561 text_editor->setTabToNextField(ignore_tabs);
1562
1563 1585
1564 text_editor->setTextEditorParameters(node); 1586 text_editor->setTextEditorParameters(node);
1565 1587
@@ -1567,7 +1589,7 @@ LLView* LLViewerTextEditor::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlF
1567 node->getAttributeBOOL("hide_scrollbar",hide_scrollbar); 1589 node->getAttributeBOOL("hide_scrollbar",hide_scrollbar);
1568 text_editor->setHideScrollbarForShortDocs(hide_scrollbar); 1590 text_editor->setHideScrollbarForShortDocs(hide_scrollbar);
1569 1591
1570 BOOL hide_border = !text_editor->mBorder->getVisible(); 1592 BOOL hide_border = !text_editor->isBorderVisible();
1571 node->getAttributeBOOL("hide_border", hide_border); 1593 node->getAttributeBOOL("hide_border", hide_border);
1572 text_editor->setBorderVisible(!hide_border); 1594 text_editor->setBorderVisible(!hide_border);
1573 1595