aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llui/lltexteditor.cpp
diff options
context:
space:
mode:
authorDavid Seikel2011-04-26 21:30:21 +1000
committerDavid Seikel2011-04-26 21:30:21 +1000
commitda97e24c3b045d16589124496d032ffb9b4ca07f (patch)
tree34d84cf4355f83e1a106d06a10ed2a4bb121fdc4 /linden/indra/llui/lltexteditor.cpp
parentApparently there is a wrong client tag for firestorm out in the wild. (diff)
parentChanged version to Experimental 2011.04.19 (diff)
downloadmeta-impy-da97e24c3b045d16589124496d032ffb9b4ca07f.zip
meta-impy-da97e24c3b045d16589124496d032ffb9b4ca07f.tar.gz
meta-impy-da97e24c3b045d16589124496d032ffb9b4ca07f.tar.bz2
meta-impy-da97e24c3b045d16589124496d032ffb9b4ca07f.tar.xz
Merge remote-tracking branch 'imprudence/exp' into exp
Conflicts (for future reference): linden/indra/llcommon/llstring.cpp linden/indra/newview/llpanelnetwork.cpp linden/indra/newview/llselectmgr.cpp linden/indra/newview/llstartup.cpp linden/indra/newview/lltoolmgr.cpp linden/indra/newview/llvoavatar.cpp
Diffstat (limited to '')
-rw-r--r--linden/indra/llui/lltexteditor.cpp148
1 files changed, 94 insertions, 54 deletions
diff --git a/linden/indra/llui/lltexteditor.cpp b/linden/indra/llui/lltexteditor.cpp
index 40dafcd..28859b1 100644
--- a/linden/indra/llui/lltexteditor.cpp
+++ b/linden/indra/llui/lltexteditor.cpp
@@ -385,43 +385,18 @@ LLTextEditor::LLTextEditor(
385 mHTML.clear(); 385 mHTML.clear();
386 386
387 // make the popup menu available 387 // make the popup menu available
388 //LLMenuGL* menu = LLUICtrlFactory::getInstance()->buildMenu("menu_texteditor.xml", parent_view); 388
389 LLMenuGL* menu = new LLMenuGL("wot"); 389 LLMenuGL* menu = LLUICtrlFactory::getInstance()->buildMenu("menu_rightclick_text.xml",this);
390 /*if (!menu) 390 if (!menu)
391 { 391 {
392 menu = new LLMenuGL(LLStringUtil::null); 392 menu = new LLMenuGL(LLStringUtil::null);
393 }*/ 393 }
394 menu->append(new LLMenuItemCallGL("Cut", context_cut, context_enable_cut, this)); 394
395 menu->append(new LLMenuItemCallGL("Copy", context_copy, context_enable_copy, this)); 395 defineMenuCallbacks(menu);
396 menu->append(new LLMenuItemCallGL("Paste", context_paste, context_enable_paste, this));
397 menu->append(new LLMenuItemCallGL("Delete", context_delete, context_enable_delete, this));
398 menu->append(new LLMenuItemCallGL("Select All", context_selectall, context_enable_selectall, this));
399 menu->appendSeparator("Transep");
400 LLMenuGL* translatemenu = new LLMenuGL("Translate To");
401 translatemenu->setCanTearOff(FALSE);
402 translatemenu->append(new LLMenuItemCallGL("en", "English", context_translate, context_enable_translate, this));
403 translatemenu->append(new LLMenuItemCallGL("da", "Danish", context_translate, context_enable_translate, this));
404 translatemenu->append(new LLMenuItemCallGL("de", "Deutsch(German)", context_translate, context_enable_translate, this));
405 translatemenu->append(new LLMenuItemCallGL("es", "Spanish", context_translate, context_enable_translate, this));
406 translatemenu->append(new LLMenuItemCallGL("fr", "French", context_translate, context_enable_translate, this));
407 translatemenu->append(new LLMenuItemCallGL("it", "Italian", context_translate, context_enable_translate, this));
408 translatemenu->append(new LLMenuItemCallGL("hu", "Hungarian", context_translate, context_enable_translate, this));
409 translatemenu->append(new LLMenuItemCallGL("nl", "Dutch", context_translate, context_enable_translate, this));
410 translatemenu->append(new LLMenuItemCallGL("pl", "Polish", context_translate, context_enable_translate, this));
411 translatemenu->append(new LLMenuItemCallGL("pt", "Portugese", context_translate, context_enable_translate, this));
412 translatemenu->append(new LLMenuItemCallGL("ru", "Russian", context_translate, context_enable_translate, this));
413 translatemenu->append(new LLMenuItemCallGL("tr", "Turkish", context_translate, context_enable_translate, this));
414 translatemenu->append(new LLMenuItemCallGL("uk", "Ukrainian", context_translate, context_enable_translate, this));
415 translatemenu->append(new LLMenuItemCallGL("zh", "Chinese", context_translate, context_enable_translate, this));
416 translatemenu->append(new LLMenuItemCallGL("ja", "Japanese", context_translate, context_enable_translate, this));
417 translatemenu->append(new LLMenuItemCallGL("ko", "Korean", context_translate, context_enable_translate, this));
418
419 menu->appendMenu(translatemenu);
420 menu->appendSeparator("Spelsep");
421 //menu->setBackgroundColor(gColors.getColor("MenuPopupBgColor"));
422 menu->setCanTearOff(FALSE);
423 menu->setVisible(FALSE);
424 mPopupMenuHandle = menu->getHandle(); 396 mPopupMenuHandle = menu->getHandle();
397 menu->setBorderColor(gColors.getColor("MenuItemDisabledColor"));
398 menu->setBackgroundColor(gColors.getColor("MenuPopupBgColor"));
399
425} 400}
426 401
427LLTextEditor::~LLTextEditor() 402LLTextEditor::~LLTextEditor()
@@ -476,7 +451,7 @@ void LLTextEditor::context_translate(void * data)
476{ 451{
477 LLTextEditor* line = (LLTextEditor*)data; 452 LLTextEditor* line = (LLTextEditor*)data;
478 LLMenuGL* menu = line ? (LLMenuGL*)(line->mPopupMenuHandle.get()) : NULL; 453 LLMenuGL* menu = line ? (LLMenuGL*)(line->mPopupMenuHandle.get()) : NULL;
479 LLMenuGL* translate_menu = menu ? menu->getChildMenuByName("Translate To", TRUE) : NULL; 454 LLMenuGL* translate_menu = menu ? menu->getChildMenuByName("Translation Options", TRUE) : NULL;
480 if (!translate_menu) 455 if (!translate_menu)
481 { 456 {
482 return; 457 return;
@@ -530,10 +505,10 @@ void LLTextEditor::spell_show(void * data)
530 } 505 }
531} 506}
532 507
533std::vector<S32> LLTextEditor::getMisspelledWordsPositions() 508void LLTextEditor::getMisspelledWordsPositions(std::vector<S32>& misspell_positions)
534{ 509{
535 resetSpellDirty(); 510 resetSpellDirty();
536 std::vector<S32> thePosesOfBadWords; 511 misspell_positions.clear();
537 LLWString& text = mWText; 512 LLWString& text = mWText;
538 S32 wordStart=0; 513 S32 wordStart=0;
539 S32 wordEnd=spellStart;//start at the scroll start 514 S32 wordEnd=spellStart;//start at the scroll start
@@ -552,23 +527,26 @@ std::vector<S32> LLTextEditor::getMisspelledWordsPositions()
552 { 527 {
553 wordEnd++; 528 wordEnd++;
554 } 529 }
555 //got a word :D
556
557 std::string regText(text.begin(),text.end());
558 std::string selectedWord(regText.substr(wordStart,wordEnd-wordStart));
559 530
560 if(!glggHunSpell->isSpelledRight(selectedWord)) 531 //got a word? -- MC
561 { 532 if (wordStart != wordEnd)
562 //misspelled word here, and you have just right clicked on it 533 {
534 std::string regText(text.begin(),text.end());
535 std::string selectedWord(regText.substr(wordStart,wordEnd-wordStart));
536
537 if(!selectedWord.empty() && !glggHunSpell->isSpelledRight(selectedWord))
538 {
539 //misspelled word here, and you have just right clicked on it
563 540
564 thePosesOfBadWords.push_back(wordStart); 541 misspell_positions.push_back(wordStart);
565 thePosesOfBadWords.push_back(wordEnd); 542 misspell_positions.push_back(wordEnd);
543 }
566 } 544 }
567 } 545 }
568 wordEnd++; 546 wordEnd++;
569 } 547 }
570 return thePosesOfBadWords;
571} 548}
549
572void LLTextEditor::spell_add(void* data) 550void LLTextEditor::spell_add(void* data)
573{ 551{
574 SpellMenuBind* tempBind = (SpellMenuBind*)data; 552 SpellMenuBind* tempBind = (SpellMenuBind*)data;
@@ -615,6 +593,68 @@ void LLTextEditor::context_selectall(void* data)
615 if(line)line->selectAll(); 593 if(line)line->selectAll();
616} 594}
617 595
596// method to define the associated callbacks
597void LLTextEditor::defineMenuCallbacks(LLMenuGL* menu) {
598
599 menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_ENABLE,
600 "Cut Text",
601 this,
602 (void*)context_enable_cut);
603 menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_CLICK,
604 "Cut Text",
605 this,
606 (void*)context_cut);
607
608 menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_ENABLE,
609 "Copy Text",
610 this,
611 (void*)context_enable_copy);
612 menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_CLICK,
613 "Copy Text",
614 this,
615 (void*)context_copy);
616
617 menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_ENABLE,
618 "Paste Text",
619 this,
620 (void*)context_enable_paste);
621 menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_CLICK,
622 "Paste Text",
623 this,
624 (void*)context_paste);
625
626 menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_ENABLE,
627 "Delete Text",
628 this,
629 (void*)context_enable_delete);
630 menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_CLICK,
631 "Delete Text",
632 this,
633 (void*)context_delete);
634
635 menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_ENABLE,
636 "Select All Text",
637 this,
638 (void*)context_enable_selectall);
639 menu->setCtrlResponse(1+LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_CLICK,
640 "Select All Text",
641 this,
642 (void*)context_selectall);
643
644 menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_ENABLE,
645 "Translate Text",
646 this,
647 (void*)context_enable_translate);
648 menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_TRANSLATE,
649 "Translate Text",
650 this,
651 (void*)context_translate);
652
653
654
655}
656
657
618void LLTextEditor::setTrackColor( const LLColor4& color ) 658void LLTextEditor::setTrackColor( const LLColor4& color )
619{ 659{
620 mScrollbar->setTrackColor(color); 660 mScrollbar->setTrackColor(color);
@@ -3240,16 +3280,16 @@ void LLTextEditor::drawMisspelled()
3240 { 3280 {
3241 spellEnd = newSpellEnd; 3281 spellEnd = newSpellEnd;
3242 spellStart = newSpellStart; 3282 spellStart = newSpellStart;
3243 misspellLocations = getMisspelledWordsPositions(); 3283 getMisspelledWordsPositions(mMisspellLocations);
3244 } 3284 }
3245 } 3285 }
3246 //draw 3286 //draw
3247 if (glggHunSpell->getSpellCheckHighlight()) 3287 if (!mMisspellLocations.empty() && glggHunSpell->getSpellCheckHighlight())
3248 { 3288 {
3249 for (int i = 0; i<(int)misspellLocations.size() ;i++) 3289 for (int i = 0; i<(int)mMisspellLocations.size() ;i++)
3250 { 3290 {
3251 S32 wstart = misspellLocations[i]; 3291 S32 wstart = mMisspellLocations[i];
3252 S32 wend = misspellLocations[++i]; 3292 S32 wend = mMisspellLocations[++i];
3253 //start curor code mod 3293 //start curor code mod
3254 const LLWString &text = mWText; 3294 const LLWString &text = mWText;
3255 const S32 text_len = getLength(); 3295 const S32 text_len = getLength();