diff options
author | McCabe Maxsted | 2010-09-16 00:21:54 -0700 |
---|---|---|
committer | McCabe Maxsted | 2010-09-16 00:21:54 -0700 |
commit | 215327d375c72d07949314a164faa0fdcbad94dc (patch) | |
tree | b1d3603490c7bea49586457a28ea664747d14d3c | |
parent | More spell checking cleanup (diff) | |
download | meta-impy-215327d375c72d07949314a164faa0fdcbad94dc.zip meta-impy-215327d375c72d07949314a164faa0fdcbad94dc.tar.gz meta-impy-215327d375c72d07949314a164faa0fdcbad94dc.tar.bz2 meta-impy-215327d375c72d07949314a164faa0fdcbad94dc.tar.xz |
Fixed up the logic for the Hide Misspellings/Show Misspellings menu options. They now toggle spell check for a specific line/text editor consistently
-rw-r--r-- | linden/indra/llui/lllineeditor.cpp | 28 | ||||
-rw-r--r-- | linden/indra/llui/lllineeditor.h | 5 | ||||
-rw-r--r-- | linden/indra/llui/lltexteditor.cpp | 22 | ||||
-rw-r--r-- | linden/indra/llui/lltexteditor.h | 5 |
4 files changed, 39 insertions, 21 deletions
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, | |||
171 | mHaveHistory(FALSE), | 171 | mHaveHistory(FALSE), |
172 | mImage( sImage ), | 172 | mImage( sImage ), |
173 | mReplaceNewlinesWithSpaces( TRUE ), | 173 | mReplaceNewlinesWithSpaces( TRUE ), |
174 | mShowMisspellings( FALSE ) | 174 | mSpellCheckable( FALSE ), |
175 | mShowMisspellings(FALSE) | ||
175 | { | 176 | { |
176 | llassert( max_length_bytes > 0 ); | 177 | llassert( max_length_bytes > 0 ); |
177 | 178 | ||
@@ -209,6 +210,13 @@ LLLineEditor::LLLineEditor(const std::string& name, const LLRect& rect, | |||
209 | sImage = LLUI::getUIImage("sm_rounded_corners_simple.tga"); | 210 | sImage = LLUI::getUIImage("sm_rounded_corners_simple.tga"); |
210 | } | 211 | } |
211 | mImage = sImage; | 212 | mImage = sImage; |
213 | |||
214 | // in other words, highlighting requires a restart | ||
215 | if (glggHunSpell->getSpellCheckHighlight()) | ||
216 | { | ||
217 | mShowMisspellings = TRUE; | ||
218 | } | ||
219 | |||
212 | // make the popup menu available | 220 | // make the popup menu available |
213 | //LLMenuGL* menu = LLUICtrlFactory::getInstance()->buildMenu("menu_texteditor.xml", parent_view); | 221 | //LLMenuGL* menu = LLUICtrlFactory::getInstance()->buildMenu("menu_texteditor.xml", parent_view); |
214 | LLMenuGL* menu = new LLMenuGL("wot"); | 222 | LLMenuGL* menu = new LLMenuGL("wot"); |
@@ -550,11 +558,11 @@ void LLLineEditor::spell_show(void * data) | |||
550 | { | 558 | { |
551 | if (tempBind->word == "Show Misspellings") | 559 | if (tempBind->word == "Show Misspellings") |
552 | { | 560 | { |
553 | line->setShowMisspellings(TRUE); | 561 | line->mShowMisspellings = TRUE; |
554 | } | 562 | } |
555 | else | 563 | else |
556 | { | 564 | { |
557 | line->setShowMisspellings(FALSE); | 565 | line->mShowMisspellings = FALSE; |
558 | } | 566 | } |
559 | } | 567 | } |
560 | } | 568 | } |
@@ -757,7 +765,7 @@ BOOL LLLineEditor::handleRightMouseDown( S32 x, S32 y, MASK mask ) | |||
757 | menu->setItemVisible("Transep", !mReadOnly); | 765 | menu->setItemVisible("Transep", !mReadOnly); |
758 | 766 | ||
759 | // spell_check="true" in xui | 767 | // spell_check="true" in xui |
760 | if (!mReadOnly && mShowMisspellings) | 768 | if (!mReadOnly && mSpellCheckable) |
761 | { | 769 | { |
762 | const LLWString& text = mText.getWString(); | 770 | const LLWString& text = mText.getWString(); |
763 | 771 | ||
@@ -813,7 +821,7 @@ BOOL LLLineEditor::handleRightMouseDown( S32 x, S32 y, MASK mask ) | |||
813 | 821 | ||
814 | SpellMenuBind * tempStruct = new SpellMenuBind; | 822 | SpellMenuBind * tempStruct = new SpellMenuBind; |
815 | tempStruct->origin = this; | 823 | tempStruct->origin = this; |
816 | if (glggHunSpell->getSpellCheckHighlight()) | 824 | if (mShowMisspellings) |
817 | { | 825 | { |
818 | tempStruct->word = "Hide Misspellings"; | 826 | tempStruct->word = "Hide Misspellings"; |
819 | } | 827 | } |
@@ -1899,7 +1907,7 @@ void LLLineEditor::autoCorrectText() | |||
1899 | 1907 | ||
1900 | void LLLineEditor::drawMisspelled(LLRect background) | 1908 | void LLLineEditor::drawMisspelled(LLRect background) |
1901 | { | 1909 | { |
1902 | if (!mReadOnly && mShowMisspellings) | 1910 | if (!mReadOnly && mSpellCheckable) |
1903 | { | 1911 | { |
1904 | S32 newStartSpellHere = mScrollHPos; | 1912 | S32 newStartSpellHere = mScrollHPos; |
1905 | S32 cursorloc = calculateCursorFromMouse(mMaxHPixels); | 1913 | S32 cursorloc = calculateCursorFromMouse(mMaxHPixels); |
@@ -1917,7 +1925,7 @@ void LLLineEditor::drawMisspelled(LLRect background) | |||
1917 | } | 1925 | } |
1918 | } | 1926 | } |
1919 | 1927 | ||
1920 | if (glggHunSpell->getSpellCheckHighlight()) | 1928 | if (mShowMisspellings) |
1921 | { | 1929 | { |
1922 | for (int i =0; i<(int)misspellLocations.size(); i++) | 1930 | for (int i =0; i<(int)misspellLocations.size(); i++) |
1923 | { | 1931 | { |
@@ -2817,10 +2825,10 @@ LLView* LLLineEditor::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory | |||
2817 | { | 2825 | { |
2818 | line_editor->setCommitOnFocusLost(commit_on_focus_lost); | 2826 | line_editor->setCommitOnFocusLost(commit_on_focus_lost); |
2819 | } | 2827 | } |
2820 | BOOL show_misspellings = FALSE; | 2828 | BOOL spell_checking = FALSE; |
2821 | if (node->getAttributeBOOL("spell_check", show_misspellings)) | 2829 | if (node->getAttributeBOOL("spell_check", spell_checking)) |
2822 | { | 2830 | { |
2823 | line_editor->setShowMisspellings(show_misspellings); | 2831 | line_editor->setSpellCheckable(spell_checking); |
2824 | } | 2832 | } |
2825 | 2833 | ||
2826 | line_editor->setColorParameters(node); | 2834 | 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: | |||
198 | void setWriteableBgColor( const LLColor4& c ) { mWriteableBgColor = c; } | 198 | void setWriteableBgColor( const LLColor4& c ) { mWriteableBgColor = c; } |
199 | void setReadOnlyBgColor( const LLColor4& c ) { mReadOnlyBgColor = c; } | 199 | void setReadOnlyBgColor( const LLColor4& c ) { mReadOnlyBgColor = c; } |
200 | void setFocusBgColor(const LLColor4& c) { mFocusBgColor = c; } | 200 | void setFocusBgColor(const LLColor4& c) { mFocusBgColor = c; } |
201 | void setShowMisspellings(BOOL b) { mShowMisspellings = b;} | 201 | void setSpellCheckable(BOOL b) { mSpellCheckable = b; } |
202 | 202 | ||
203 | const LLColor4& getFgColor() const { return mFgColor; } | 203 | const LLColor4& getFgColor() const { return mFgColor; } |
204 | const LLColor4& getReadOnlyFgColor() const { return mReadOnlyFgColor; } | 204 | const LLColor4& getReadOnlyFgColor() const { return mReadOnlyFgColor; } |
@@ -293,7 +293,8 @@ protected: | |||
293 | std::vector<S32> misspellLocations; // where all the mispelled words are | 293 | std::vector<S32> misspellLocations; // where all the mispelled words are |
294 | S32 mStartSpellHere; // the position of the first char on the screen, stored so we know when to update | 294 | S32 mStartSpellHere; // the position of the first char on the screen, stored so we know when to update |
295 | S32 mEndSpellHere; // the location of the last char on the screen | 295 | S32 mEndSpellHere; // the location of the last char on the screen |
296 | BOOL mShowMisspellings; | 296 | BOOL mSpellCheckable; // set in xui as "spell_check". Default value for a field |
297 | BOOL mShowMisspellings; // show misspellings as highlighted (initialized in the ctor) | ||
297 | LLFrameTimer mSpellTimer; | 298 | LLFrameTimer mSpellTimer; |
298 | //to keep track of what we have to remove before showing menu | 299 | //to keep track of what we have to remove before showing menu |
299 | std::vector<SpellMenuBind* > suggestionMenuItems; | 300 | std::vector<SpellMenuBind* > 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( | |||
323 | mLastSelectionY(-1), | 323 | mLastSelectionY(-1), |
324 | mReflowNeeded(FALSE), | 324 | mReflowNeeded(FALSE), |
325 | mScrollNeeded(FALSE), | 325 | mScrollNeeded(FALSE), |
326 | mSpellCheckable(FALSE), | ||
326 | mShowMisspellings(FALSE) | 327 | mShowMisspellings(FALSE) |
327 | { | 328 | { |
328 | mSourceID.generate(); | 329 | mSourceID.generate(); |
@@ -375,6 +376,13 @@ LLTextEditor::LLTextEditor( | |||
375 | 376 | ||
376 | mParseHTML=FALSE; | 377 | mParseHTML=FALSE; |
377 | mHTML.clear(); | 378 | mHTML.clear(); |
379 | |||
380 | // in other words, highlighting requires a restart | ||
381 | if (glggHunSpell->getSpellCheckHighlight()) | ||
382 | { | ||
383 | mShowMisspellings = TRUE; | ||
384 | } | ||
385 | |||
378 | // make the popup menu available | 386 | // make the popup menu available |
379 | //LLMenuGL* menu = LLUICtrlFactory::getInstance()->buildMenu("menu_texteditor.xml", parent_view); | 387 | //LLMenuGL* menu = LLUICtrlFactory::getInstance()->buildMenu("menu_texteditor.xml", parent_view); |
380 | LLMenuGL* menu = new LLMenuGL("wot"); | 388 | LLMenuGL* menu = new LLMenuGL("wot"); |
@@ -490,11 +498,11 @@ void LLTextEditor::spell_show(void * data) | |||
490 | { | 498 | { |
491 | if (tempBind->word == "Show Misspellings") | 499 | if (tempBind->word == "Show Misspellings") |
492 | { | 500 | { |
493 | line->setShowMisspellings(TRUE); | 501 | glggHunSpell->setSpellCheckHighlight(TRUE); |
494 | } | 502 | } |
495 | else | 503 | else |
496 | { | 504 | { |
497 | line->setShowMisspellings(FALSE); | 505 | glggHunSpell->setSpellCheckHighlight(FALSE); |
498 | } | 506 | } |
499 | } | 507 | } |
500 | } | 508 | } |
@@ -1454,7 +1462,7 @@ BOOL LLTextEditor::handleRightMouseDown( S32 x, S32 y, MASK mask ) | |||
1454 | menu->setItemVisible("Transep", !mReadOnly); | 1462 | menu->setItemVisible("Transep", !mReadOnly); |
1455 | 1463 | ||
1456 | // spell_check="true" in xui | 1464 | // spell_check="true" in xui |
1457 | if (!mReadOnly && mShowMisspellings) | 1465 | if (!mReadOnly && mSpellCheckable) |
1458 | { | 1466 | { |
1459 | const LLWString &text = mWText; | 1467 | const LLWString &text = mWText; |
1460 | 1468 | ||
@@ -1509,7 +1517,7 @@ BOOL LLTextEditor::handleRightMouseDown( S32 x, S32 y, MASK mask ) | |||
1509 | 1517 | ||
1510 | SpellMenuBind * tempStruct = new SpellMenuBind; | 1518 | SpellMenuBind * tempStruct = new SpellMenuBind; |
1511 | tempStruct->origin = this; | 1519 | tempStruct->origin = this; |
1512 | if (glggHunSpell->getSpellCheckHighlight()) | 1520 | if (mShowMisspellings) |
1513 | { | 1521 | { |
1514 | tempStruct->word = "Hide Misspellings"; | 1522 | tempStruct->word = "Hide Misspellings"; |
1515 | } | 1523 | } |
@@ -3131,7 +3139,7 @@ void LLTextEditor::autoCorrectText() | |||
3131 | 3139 | ||
3132 | void LLTextEditor::drawMisspelled() | 3140 | void LLTextEditor::drawMisspelled() |
3133 | { | 3141 | { |
3134 | if (!mReadOnly && mShowMisspellings) | 3142 | if (!mReadOnly && mSpellCheckable) |
3135 | { | 3143 | { |
3136 | if( | 3144 | if( |
3137 | ( ((getLength()<400)||(false)) &&( (S32(mSpellTimer.getElapsedTimeF32() / 1) & 1) )) | 3145 | ( ((getLength()<400)||(false)) &&( (S32(mSpellTimer.getElapsedTimeF32() / 1) & 1) )) |
@@ -3154,7 +3162,7 @@ void LLTextEditor::drawMisspelled() | |||
3154 | } | 3162 | } |
3155 | } | 3163 | } |
3156 | //draw | 3164 | //draw |
3157 | if (glggHunSpell->getSpellCheckHighlight()) | 3165 | if (mShowMisspellings) |
3158 | { | 3166 | { |
3159 | for (int i = 0; i<(int)misspellLocations.size() ;i++) | 3167 | for (int i = 0; i<(int)misspellLocations.size() ;i++) |
3160 | { | 3168 | { |
@@ -4891,7 +4899,7 @@ void LLTextEditor::setTextEditorParameters(LLXMLNodePtr node) | |||
4891 | 4899 | ||
4892 | node->getAttributeBOOL("track_bottom", mTrackBottom); | 4900 | node->getAttributeBOOL("track_bottom", mTrackBottom); |
4893 | 4901 | ||
4894 | node->getAttributeBOOL("spell_check", mShowMisspellings); | 4902 | node->getAttributeBOOL("spell_check", mSpellCheckable); |
4895 | 4903 | ||
4896 | LLColor4 color; | 4904 | LLColor4 color; |
4897 | if (LLUICtrlFactory::getAttributeColor(node,"cursor_color", color)) | 4905 | 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: | |||
229 | void setThumbColor( const LLColor4& color ); | 229 | void setThumbColor( const LLColor4& color ); |
230 | void setHighlightColor( const LLColor4& color ); | 230 | void setHighlightColor( const LLColor4& color ); |
231 | void setShadowColor( const LLColor4& color ); | 231 | void setShadowColor( const LLColor4& color ); |
232 | void setShowMisspellings(BOOL b) { mShowMisspellings = b; } | 232 | void setSpellCheckable(BOOL b) { mSpellCheckable = b; } |
233 | 233 | ||
234 | // Hacky methods to make it into a word-wrapping, potentially scrolling, | 234 | // Hacky methods to make it into a word-wrapping, potentially scrolling, |
235 | // read-only text box. | 235 | // read-only text box. |
@@ -526,7 +526,8 @@ private: | |||
526 | S32 spellStart; | 526 | S32 spellStart; |
527 | S32 spellEnd; | 527 | S32 spellEnd; |
528 | std::vector<S32> misspellLocations; // where all the mispelled words are | 528 | std::vector<S32> misspellLocations; // where all the mispelled words are |
529 | BOOL mShowMisspellings; // set in xui as "spell_check". Default value for a field | 529 | BOOL mSpellCheckable; // set in xui as "spell_check". Default value for a field |
530 | BOOL mShowMisspellings; // show misspellings as highlighted (initialized in the ctor) | ||
530 | 531 | ||
531 | S32 mMaxTextByteLength; // Maximum length mText is allowed to be in bytes | 532 | S32 mMaxTextByteLength; // Maximum length mText is allowed to be in bytes |
532 | 533 | ||