From 215327d375c72d07949314a164faa0fdcbad94dc Mon Sep 17 00:00:00 2001 From: McCabe Maxsted Date: Thu, 16 Sep 2010 00:21:54 -0700 Subject: Fixed up the logic for the Hide Misspellings/Show Misspellings menu options. They now toggle spell check for a specific line/text editor consistently --- linden/indra/llui/lllineeditor.cpp | 28 ++++++++++++++++++---------- linden/indra/llui/lllineeditor.h | 5 +++-- linden/indra/llui/lltexteditor.cpp | 22 +++++++++++++++------- linden/indra/llui/lltexteditor.h | 5 +++-- 4 files changed, 39 insertions(+), 21 deletions(-) (limited to 'linden/indra/llui') diff --git a/linden/indra/llui/lllineeditor.cpp b/linden/indra/llui/lllineeditor.cpp index 9c68fec..66ef4c6 100644 --- a/linden/indra/llui/lllineeditor.cpp +++ b/linden/indra/llui/lllineeditor.cpp @@ -171,7 +171,8 @@ LLLineEditor::LLLineEditor(const std::string& name, const LLRect& rect, mHaveHistory(FALSE), mImage( sImage ), mReplaceNewlinesWithSpaces( TRUE ), - mShowMisspellings( FALSE ) + mSpellCheckable( FALSE ), + mShowMisspellings(FALSE) { llassert( max_length_bytes > 0 ); @@ -209,6 +210,13 @@ LLLineEditor::LLLineEditor(const std::string& name, const LLRect& rect, sImage = LLUI::getUIImage("sm_rounded_corners_simple.tga"); } mImage = sImage; + + // in other words, highlighting requires a restart + if (glggHunSpell->getSpellCheckHighlight()) + { + mShowMisspellings = TRUE; + } + // make the popup menu available //LLMenuGL* menu = LLUICtrlFactory::getInstance()->buildMenu("menu_texteditor.xml", parent_view); LLMenuGL* menu = new LLMenuGL("wot"); @@ -550,11 +558,11 @@ void LLLineEditor::spell_show(void * data) { if (tempBind->word == "Show Misspellings") { - line->setShowMisspellings(TRUE); + line->mShowMisspellings = TRUE; } else { - line->setShowMisspellings(FALSE); + line->mShowMisspellings = FALSE; } } } @@ -757,7 +765,7 @@ BOOL LLLineEditor::handleRightMouseDown( S32 x, S32 y, MASK mask ) menu->setItemVisible("Transep", !mReadOnly); // spell_check="true" in xui - if (!mReadOnly && mShowMisspellings) + if (!mReadOnly && mSpellCheckable) { const LLWString& text = mText.getWString(); @@ -813,7 +821,7 @@ BOOL LLLineEditor::handleRightMouseDown( S32 x, S32 y, MASK mask ) SpellMenuBind * tempStruct = new SpellMenuBind; tempStruct->origin = this; - if (glggHunSpell->getSpellCheckHighlight()) + if (mShowMisspellings) { tempStruct->word = "Hide Misspellings"; } @@ -1899,7 +1907,7 @@ void LLLineEditor::autoCorrectText() void LLLineEditor::drawMisspelled(LLRect background) { - if (!mReadOnly && mShowMisspellings) + if (!mReadOnly && mSpellCheckable) { S32 newStartSpellHere = mScrollHPos; S32 cursorloc = calculateCursorFromMouse(mMaxHPixels); @@ -1917,7 +1925,7 @@ void LLLineEditor::drawMisspelled(LLRect background) } } - if (glggHunSpell->getSpellCheckHighlight()) + if (mShowMisspellings) { for (int i =0; i<(int)misspellLocations.size(); i++) { @@ -2817,10 +2825,10 @@ LLView* LLLineEditor::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory { line_editor->setCommitOnFocusLost(commit_on_focus_lost); } - BOOL show_misspellings = FALSE; - if (node->getAttributeBOOL("spell_check", show_misspellings)) + BOOL spell_checking = FALSE; + if (node->getAttributeBOOL("spell_check", spell_checking)) { - line_editor->setShowMisspellings(show_misspellings); + line_editor->setSpellCheckable(spell_checking); } line_editor->setColorParameters(node); diff --git a/linden/indra/llui/lllineeditor.h b/linden/indra/llui/lllineeditor.h index 1d24803..147b232 100644 --- a/linden/indra/llui/lllineeditor.h +++ b/linden/indra/llui/lllineeditor.h @@ -198,7 +198,7 @@ public: void setWriteableBgColor( const LLColor4& c ) { mWriteableBgColor = c; } void setReadOnlyBgColor( const LLColor4& c ) { mReadOnlyBgColor = c; } void setFocusBgColor(const LLColor4& c) { mFocusBgColor = c; } - void setShowMisspellings(BOOL b) { mShowMisspellings = b;} + void setSpellCheckable(BOOL b) { mSpellCheckable = b; } const LLColor4& getFgColor() const { return mFgColor; } const LLColor4& getReadOnlyFgColor() const { return mReadOnlyFgColor; } @@ -293,7 +293,8 @@ protected: std::vector misspellLocations; // where all the mispelled words are S32 mStartSpellHere; // the position of the first char on the screen, stored so we know when to update S32 mEndSpellHere; // the location of the last char on the screen - BOOL mShowMisspellings; + BOOL mSpellCheckable; // set in xui as "spell_check". Default value for a field + BOOL mShowMisspellings; // show misspellings as highlighted (initialized in the ctor) LLFrameTimer mSpellTimer; //to keep track of what we have to remove before showing menu std::vector suggestionMenuItems; diff --git a/linden/indra/llui/lltexteditor.cpp b/linden/indra/llui/lltexteditor.cpp index cf35ee7..b101588 100644 --- a/linden/indra/llui/lltexteditor.cpp +++ b/linden/indra/llui/lltexteditor.cpp @@ -323,6 +323,7 @@ LLTextEditor::LLTextEditor( mLastSelectionY(-1), mReflowNeeded(FALSE), mScrollNeeded(FALSE), + mSpellCheckable(FALSE), mShowMisspellings(FALSE) { mSourceID.generate(); @@ -375,6 +376,13 @@ LLTextEditor::LLTextEditor( mParseHTML=FALSE; mHTML.clear(); + + // in other words, highlighting requires a restart + if (glggHunSpell->getSpellCheckHighlight()) + { + mShowMisspellings = TRUE; + } + // make the popup menu available //LLMenuGL* menu = LLUICtrlFactory::getInstance()->buildMenu("menu_texteditor.xml", parent_view); LLMenuGL* menu = new LLMenuGL("wot"); @@ -490,11 +498,11 @@ void LLTextEditor::spell_show(void * data) { if (tempBind->word == "Show Misspellings") { - line->setShowMisspellings(TRUE); + glggHunSpell->setSpellCheckHighlight(TRUE); } else { - line->setShowMisspellings(FALSE); + glggHunSpell->setSpellCheckHighlight(FALSE); } } } @@ -1454,7 +1462,7 @@ BOOL LLTextEditor::handleRightMouseDown( S32 x, S32 y, MASK mask ) menu->setItemVisible("Transep", !mReadOnly); // spell_check="true" in xui - if (!mReadOnly && mShowMisspellings) + if (!mReadOnly && mSpellCheckable) { const LLWString &text = mWText; @@ -1509,7 +1517,7 @@ BOOL LLTextEditor::handleRightMouseDown( S32 x, S32 y, MASK mask ) SpellMenuBind * tempStruct = new SpellMenuBind; tempStruct->origin = this; - if (glggHunSpell->getSpellCheckHighlight()) + if (mShowMisspellings) { tempStruct->word = "Hide Misspellings"; } @@ -3131,7 +3139,7 @@ void LLTextEditor::autoCorrectText() void LLTextEditor::drawMisspelled() { - if (!mReadOnly && mShowMisspellings) + if (!mReadOnly && mSpellCheckable) { if( ( ((getLength()<400)||(false)) &&( (S32(mSpellTimer.getElapsedTimeF32() / 1) & 1) )) @@ -3154,7 +3162,7 @@ void LLTextEditor::drawMisspelled() } } //draw - if (glggHunSpell->getSpellCheckHighlight()) + if (mShowMisspellings) { for (int i = 0; i<(int)misspellLocations.size() ;i++) { @@ -4891,7 +4899,7 @@ void LLTextEditor::setTextEditorParameters(LLXMLNodePtr node) node->getAttributeBOOL("track_bottom", mTrackBottom); - node->getAttributeBOOL("spell_check", mShowMisspellings); + node->getAttributeBOOL("spell_check", mSpellCheckable); LLColor4 color; if (LLUICtrlFactory::getAttributeColor(node,"cursor_color", color)) diff --git a/linden/indra/llui/lltexteditor.h b/linden/indra/llui/lltexteditor.h index c5c3af8..57a6bbd 100644 --- a/linden/indra/llui/lltexteditor.h +++ b/linden/indra/llui/lltexteditor.h @@ -229,7 +229,7 @@ public: void setThumbColor( const LLColor4& color ); void setHighlightColor( const LLColor4& color ); void setShadowColor( const LLColor4& color ); - void setShowMisspellings(BOOL b) { mShowMisspellings = b; } + void setSpellCheckable(BOOL b) { mSpellCheckable = b; } // Hacky methods to make it into a word-wrapping, potentially scrolling, // read-only text box. @@ -526,7 +526,8 @@ private: S32 spellStart; S32 spellEnd; std::vector misspellLocations; // where all the mispelled words are - BOOL mShowMisspellings; // set in xui as "spell_check". Default value for a field + BOOL mSpellCheckable; // set in xui as "spell_check". Default value for a field + BOOL mShowMisspellings; // show misspellings as highlighted (initialized in the ctor) S32 mMaxTextByteLength; // Maximum length mText is allowed to be in bytes -- cgit v1.1