diff options
Diffstat (limited to 'linden/indra/llui')
-rw-r--r-- | linden/indra/llui/llcombobox.cpp | 7 | ||||
-rw-r--r-- | linden/indra/llui/llcombobox.h | 1 | ||||
-rw-r--r-- | linden/indra/llui/lllineeditor.cpp | 168 | ||||
-rw-r--r-- | linden/indra/llui/lllineeditor.h | 13 | ||||
-rw-r--r-- | linden/indra/llui/llmenugl.cpp | 219 | ||||
-rw-r--r-- | linden/indra/llui/llmenugl.h | 114 | ||||
-rw-r--r-- | linden/indra/llui/lltexteditor.cpp | 148 | ||||
-rw-r--r-- | linden/indra/llui/lltexteditor.h | 7 |
8 files changed, 542 insertions, 135 deletions
diff --git a/linden/indra/llui/llcombobox.cpp b/linden/indra/llui/llcombobox.cpp index a93dc9b..f3ef83e 100644 --- a/linden/indra/llui/llcombobox.cpp +++ b/linden/indra/llui/llcombobox.cpp | |||
@@ -591,6 +591,13 @@ void LLComboBox::updateLayout() | |||
591 | } | 591 | } |
592 | } | 592 | } |
593 | 593 | ||
594 | |||
595 | void LLComboBox::getAllData(std::vector<LLScrollListItem*>& item_list) const | ||
596 | { | ||
597 | item_list = mList->getAllData(); | ||
598 | } | ||
599 | |||
600 | |||
594 | void* LLComboBox::getCurrentUserdata() | 601 | void* LLComboBox::getCurrentUserdata() |
595 | { | 602 | { |
596 | LLScrollListItem* item = mList->getFirstSelected(); | 603 | LLScrollListItem* item = mList->getFirstSelected(); |
diff --git a/linden/indra/llui/llcombobox.h b/linden/indra/llui/llcombobox.h index 596f659..f92fe44 100644 --- a/linden/indra/llui/llcombobox.h +++ b/linden/indra/llui/llcombobox.h | |||
@@ -169,6 +169,7 @@ public: | |||
169 | 169 | ||
170 | //======================================================================== | 170 | //======================================================================== |
171 | 171 | ||
172 | void getAllData(std::vector<LLScrollListItem*>& item_list) const; | ||
172 | void* getCurrentUserdata(); | 173 | void* getCurrentUserdata(); |
173 | 174 | ||
174 | void setPrearrangeCallback( void (*cb)(LLUICtrl*,void*) ) { mPrearrangeCallback = cb; } | 175 | void setPrearrangeCallback( void (*cb)(LLUICtrl*,void*) ) { mPrearrangeCallback = cb; } |
diff --git a/linden/indra/llui/lllineeditor.cpp b/linden/indra/llui/lllineeditor.cpp index a21ad5d..453bb50 100644 --- a/linden/indra/llui/lllineeditor.cpp +++ b/linden/indra/llui/lllineeditor.cpp | |||
@@ -55,17 +55,24 @@ | |||
55 | #include "llui.h" | 55 | #include "llui.h" |
56 | #include "lluictrlfactory.h" | 56 | #include "lluictrlfactory.h" |
57 | #include "llclipboard.h" | 57 | #include "llclipboard.h" |
58 | #include "llmemberlistener.h" | ||
58 | 59 | ||
59 | #include "../newview/lgghunspell_wrapper.h" | 60 | #include "../newview/lgghunspell_wrapper.h" |
60 | #include "../newview/lltranslate.h" | 61 | #include "../newview/lltranslate.h" |
61 | #include "../newview/llviewercontrol.h" | 62 | #include "../newview/llviewercontrol.h" |
62 | #include "../newview/lggautocorrect.h" | 63 | #include "../newview/lggautocorrect.h" |
63 | 64 | ||
65 | |||
64 | // | 66 | // |
65 | // Imported globals | 67 | // Imported globals |
66 | // | 68 | // |
67 | 69 | ||
68 | // | 70 | // |
71 | // Globals | ||
72 | |||
73 | |||
74 | |||
75 | // | ||
69 | // Constants | 76 | // Constants |
70 | // | 77 | // |
71 | 78 | ||
@@ -90,6 +97,8 @@ static LLRegisterWidget<LLLineEditor> r1("line_editor"); | |||
90 | 97 | ||
91 | /* static */ LLPointer<LLUIImage> LLLineEditor::sImage; | 98 | /* static */ LLPointer<LLUIImage> LLLineEditor::sImage; |
92 | 99 | ||
100 | typedef LLMemberListener<LLView> text_edit_listener_t; | ||
101 | |||
93 | // | 102 | // |
94 | // Member functions | 103 | // Member functions |
95 | // | 104 | // |
@@ -214,46 +223,18 @@ LLLineEditor::LLLineEditor(const std::string& name, const LLRect& rect, | |||
214 | } | 223 | } |
215 | mImage = sImage; | 224 | mImage = sImage; |
216 | 225 | ||
217 | // make the popup menu available | 226 | |
218 | //LLMenuGL* menu = LLUICtrlFactory::getInstance()->buildMenu("menu_texteditor.xml", parent_view); | 227 | LLMenuGL* menu = LLUICtrlFactory::getInstance()->buildMenu("menu_rightclick_text.xml",this); |
219 | LLMenuGL* menu = new LLMenuGL("wot"); | 228 | if (!menu) |
220 | /*if (!menu) | 229 | { |
221 | { | 230 | menu = new LLMenuGL(LLStringUtil::null); |
222 | menu = new LLMenuGL(LLStringUtil::null); | 231 | } |
223 | }*/ | 232 | |
224 | 233 | defineMenuCallbacks(menu); | |
225 | menu->append(new LLMenuItemCallGL("Cut", context_cut, context_enable_cut, this)); | ||
226 | menu->append(new LLMenuItemCallGL("Copy", context_copy, context_enable_copy, this)); | ||
227 | menu->append(new LLMenuItemCallGL("Paste", context_paste, context_enable_paste, this)); | ||
228 | menu->append(new LLMenuItemCallGL("Delete", context_delete, context_enable_delete, this)); | ||
229 | menu->append(new LLMenuItemCallGL("Select All", context_selectall, context_enable_selectall, this)); | ||
230 | |||
231 | menu->appendSeparator("Transep"); | ||
232 | LLMenuGL* translatemenu = new LLMenuGL("Translate To"); | ||
233 | translatemenu->setCanTearOff(FALSE); | ||
234 | translatemenu->append(new LLMenuItemCallGL("en", "English", context_translate, context_enable_translate, this)); | ||
235 | translatemenu->append(new LLMenuItemCallGL("da", "Danish", context_translate, context_enable_translate, this)); | ||
236 | translatemenu->append(new LLMenuItemCallGL("de", "Deutsch(German)", context_translate, context_enable_translate, this)); | ||
237 | translatemenu->append(new LLMenuItemCallGL("es", "Spanish", context_translate, context_enable_translate, this)); | ||
238 | translatemenu->append(new LLMenuItemCallGL("fr", "French", context_translate, context_enable_translate, this)); | ||
239 | translatemenu->append(new LLMenuItemCallGL("it", "Italian", context_translate, context_enable_translate, this)); | ||
240 | translatemenu->append(new LLMenuItemCallGL("hu", "Hungarian", context_translate, context_enable_translate, this)); | ||
241 | translatemenu->append(new LLMenuItemCallGL("nl", "Dutch", context_translate, context_enable_translate, this)); | ||
242 | translatemenu->append(new LLMenuItemCallGL("pl", "Polish", context_translate, context_enable_translate, this)); | ||
243 | translatemenu->append(new LLMenuItemCallGL("pt", "Portugese", context_translate, context_enable_translate, this)); | ||
244 | translatemenu->append(new LLMenuItemCallGL("ru", "Russian", context_translate, context_enable_translate, this)); | ||
245 | translatemenu->append(new LLMenuItemCallGL("tr", "Turkish", context_translate, context_enable_translate, this)); | ||
246 | translatemenu->append(new LLMenuItemCallGL("uk", "Ukrainian", context_translate, context_enable_translate, this)); | ||
247 | translatemenu->append(new LLMenuItemCallGL("zh", "Chinese", context_translate, context_enable_translate, this)); | ||
248 | translatemenu->append(new LLMenuItemCallGL("ja", "Japanese", context_translate, context_enable_translate, this)); | ||
249 | translatemenu->append(new LLMenuItemCallGL("ko", "Korean", context_translate, context_enable_translate, this)); | ||
250 | |||
251 | menu->appendMenu(translatemenu); | ||
252 | menu->appendSeparator("Spelsep"); | ||
253 | //menu->setBackgroundColor(gColors.getColor("MenuPopupBgColor")); | ||
254 | menu->setCanTearOff(FALSE); | ||
255 | menu->setVisible(FALSE); | ||
256 | mPopupMenuHandle = menu->getHandle(); | 234 | mPopupMenuHandle = menu->getHandle(); |
235 | menu->setBorderColor(gColors.getColor("MenuItemDisabledColor")); | ||
236 | menu->setBackgroundColor(gColors.getColor("MenuPopupBgColor")); | ||
237 | |||
257 | } | 238 | } |
258 | 239 | ||
259 | 240 | ||
@@ -556,7 +537,7 @@ void LLLineEditor::context_translate(void * data) | |||
556 | { | 537 | { |
557 | LLLineEditor* line = (LLLineEditor*)data; | 538 | LLLineEditor* line = (LLLineEditor*)data; |
558 | LLMenuGL* menu = line ? (LLMenuGL*)(line->mPopupMenuHandle.get()) : NULL; | 539 | LLMenuGL* menu = line ? (LLMenuGL*)(line->mPopupMenuHandle.get()) : NULL; |
559 | LLMenuGL* translate_menu = menu ? menu->getChildMenuByName("Translate To", TRUE) : NULL; | 540 | LLMenuGL* translate_menu = menu ? menu->getChildMenuByName("Translation Options", TRUE) : NULL; |
560 | if (!translate_menu) | 541 | if (!translate_menu) |
561 | { | 542 | { |
562 | return; | 543 | return; |
@@ -599,9 +580,9 @@ void LLLineEditor::spell_show(void * data) | |||
599 | } | 580 | } |
600 | } | 581 | } |
601 | 582 | ||
602 | std::vector<S32> LLLineEditor::getMisspelledWordsPositions() | 583 | void LLLineEditor::getMisspelledWordsPositions(std::vector<S32>& misspell_positions) |
603 | { | 584 | { |
604 | std::vector<S32> thePosesOfBadWords; | 585 | misspell_positions.clear(); |
605 | const LLWString& text = mText.getWString(); | 586 | const LLWString& text = mText.getWString(); |
606 | 587 | ||
607 | //llinfos << "end of box is at " << cursorloc << " and end of text is at " << text.length() << llendl; | 588 | //llinfos << "end of box is at " << cursorloc << " and end of text is at " << text.length() << llendl; |
@@ -623,26 +604,28 @@ std::vector<S32> LLLineEditor::getMisspelledWordsPositions() | |||
623 | { | 604 | { |
624 | wordEnd++; | 605 | wordEnd++; |
625 | } | 606 | } |
626 | //got a word :D | ||
627 | std::string selectedWord(std::string(text.begin(), | ||
628 | text.end()).substr(wordStart,wordEnd-wordStart)); | ||
629 | 607 | ||
630 | if(!glggHunSpell->isSpelledRight(selectedWord)) | 608 | //got a word? -- MC |
631 | { | 609 | if (wordStart != wordEnd) |
632 | //misspelled word here, and you have just right clicked on it! | 610 | { |
633 | //get the center of this word.. | 611 | std::string selectedWord(std::string(text.begin(), |
634 | //S32 center = llround( (wordEnd-wordStart)/2 ) + wordStart; | 612 | text.end()).substr(wordStart,wordEnd-wordStart)); |
635 | //turn this cursor position into a pixel pos | 613 | |
636 | //center = findPixelNearestPos(center-getCursor()); | 614 | if(!selectedWord.empty() && !glggHunSpell->isSpelledRight(selectedWord)) |
615 | { | ||
616 | //misspelled word here, and you have just right clicked on it! | ||
617 | //get the center of this word.. | ||
618 | //S32 center = llround( (wordEnd-wordStart)/2 ) + wordStart; | ||
619 | //turn this cursor position into a pixel pos | ||
620 | //center = findPixelNearestPos(center-getCursor()); | ||
637 | 621 | ||
638 | thePosesOfBadWords.push_back( | 622 | misspell_positions.push_back(wordStart); |
639 | wordStart); | 623 | misspell_positions.push_back(wordEnd); |
640 | thePosesOfBadWords.push_back(wordEnd); | 624 | } |
641 | } | 625 | } |
642 | } | 626 | } |
643 | wordEnd++; | 627 | wordEnd++; |
644 | } | 628 | } |
645 | return thePosesOfBadWords; | ||
646 | } | 629 | } |
647 | 630 | ||
648 | void LLLineEditor::spell_add(void* data) | 631 | void LLLineEditor::spell_add(void* data) |
@@ -1318,6 +1301,67 @@ BOOL LLLineEditor::canCut() const | |||
1318 | return !mReadOnly && !mDrawAsterixes && hasSelection(); | 1301 | return !mReadOnly && !mDrawAsterixes && hasSelection(); |
1319 | } | 1302 | } |
1320 | 1303 | ||
1304 | // method to define the associated callbacks | ||
1305 | void LLLineEditor::defineMenuCallbacks(LLMenuGL* menu) { | ||
1306 | |||
1307 | menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_ENABLE, | ||
1308 | "Cut Text", | ||
1309 | this, | ||
1310 | (void*)context_enable_cut); | ||
1311 | menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_CLICK, | ||
1312 | "Cut Text", | ||
1313 | this, | ||
1314 | (void*)context_cut); | ||
1315 | |||
1316 | menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_ENABLE, | ||
1317 | "Copy Text", | ||
1318 | this, | ||
1319 | (void*)context_enable_copy); | ||
1320 | menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_CLICK, | ||
1321 | "Copy Text", | ||
1322 | this, | ||
1323 | (void*)context_copy); | ||
1324 | |||
1325 | menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_ENABLE, | ||
1326 | "Paste Text", | ||
1327 | this, | ||
1328 | (void*)context_enable_paste); | ||
1329 | menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_CLICK, | ||
1330 | "Paste Text", | ||
1331 | this, | ||
1332 | (void*)context_paste); | ||
1333 | |||
1334 | menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_ENABLE, | ||
1335 | "Delete Text", | ||
1336 | this, | ||
1337 | (void*)context_enable_delete); | ||
1338 | menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_CLICK, | ||
1339 | "Delete Text", | ||
1340 | this, | ||
1341 | (void*)context_delete); | ||
1342 | |||
1343 | menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_ENABLE, | ||
1344 | "Select All Text", | ||
1345 | this, | ||
1346 | (void*)context_enable_selectall); | ||
1347 | menu->setCtrlResponse(1+LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_CLICK, | ||
1348 | "Select All Text", | ||
1349 | this, | ||
1350 | (void*)context_selectall); | ||
1351 | |||
1352 | menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_ENABLE, | ||
1353 | "Translate Text", | ||
1354 | this, | ||
1355 | (void*)context_enable_translate); | ||
1356 | menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_TRANSLATE, | ||
1357 | "Translate Text", | ||
1358 | this, | ||
1359 | (void*)context_translate); | ||
1360 | |||
1361 | |||
1362 | |||
1363 | } | ||
1364 | |||
1321 | // cut selection to clipboard | 1365 | // cut selection to clipboard |
1322 | void LLLineEditor::cut() | 1366 | void LLLineEditor::cut() |
1323 | { | 1367 | { |
@@ -1994,7 +2038,7 @@ void LLLineEditor::autoCorrectText() | |||
1994 | } | 2038 | } |
1995 | } | 2039 | } |
1996 | 2040 | ||
1997 | void LLLineEditor::drawMisspelled(LLRect background) | 2041 | void LLLineEditor::drawMisspelled(const LLRect& background) |
1998 | { | 2042 | { |
1999 | if (!mReadOnly && mSpellCheckable) | 2043 | if (!mReadOnly && mSpellCheckable) |
2000 | { | 2044 | { |
@@ -2010,16 +2054,16 @@ void LLLineEditor::drawMisspelled(LLRect background) | |||
2010 | mStartSpellHere = newStartSpellHere; | 2054 | mStartSpellHere = newStartSpellHere; |
2011 | mEndSpellHere = newStopSpellHere; | 2055 | mEndSpellHere = newStopSpellHere; |
2012 | resetSpellDirty(); | 2056 | resetSpellDirty(); |
2013 | misspellLocations=getMisspelledWordsPositions(); | 2057 | getMisspelledWordsPositions(mMisspellLocations); |
2014 | } | 2058 | } |
2015 | } | 2059 | } |
2016 | 2060 | ||
2017 | if (glggHunSpell->getSpellCheckHighlight()) | 2061 | if (!mMisspellLocations.empty() && glggHunSpell->getSpellCheckHighlight()) |
2018 | { | 2062 | { |
2019 | for (int i =0; i<(int)misspellLocations.size(); i++) | 2063 | for (int i =0; i<(int)mMisspellLocations.size(); i++) |
2020 | { | 2064 | { |
2021 | S32 wstart =findPixelNearestPos( misspellLocations[i]-getCursor()); | 2065 | S32 wstart =findPixelNearestPos( mMisspellLocations[i]-getCursor()); |
2022 | S32 wend = findPixelNearestPos(misspellLocations[++i]-getCursor()); | 2066 | S32 wend = findPixelNearestPos(mMisspellLocations[++i]-getCursor()); |
2023 | S32 maxw = getRect().getWidth(); | 2067 | S32 maxw = getRect().getWidth(); |
2024 | 2068 | ||
2025 | if (wend > maxw) | 2069 | if (wend > maxw) |
diff --git a/linden/indra/llui/lllineeditor.h b/linden/indra/llui/lllineeditor.h index 43ce869..b3e21ce 100644 --- a/linden/indra/llui/lllineeditor.h +++ b/linden/indra/llui/lllineeditor.h | |||
@@ -55,6 +55,7 @@ | |||
55 | class LLFontGL; | 55 | class LLFontGL; |
56 | class LLLineEditorRollback; | 56 | class LLLineEditorRollback; |
57 | class LLButton; | 57 | class LLButton; |
58 | class LLMenuGL; | ||
58 | 59 | ||
59 | typedef BOOL (*LLLinePrevalidateFunc)(const LLWString &wstr); | 60 | typedef BOOL (*LLLinePrevalidateFunc)(const LLWString &wstr); |
60 | 61 | ||
@@ -112,7 +113,8 @@ public: | |||
112 | virtual BOOL canTranslate() const; | 113 | virtual BOOL canTranslate() const; |
113 | virtual void insert(std::string what,S32 wher); | 114 | virtual void insert(std::string what,S32 wher); |
114 | 115 | ||
115 | // LLEditMenuHandler overrides | 116 | // LLEditMenuHandler overrides and menu set up methods. |
117 | void defineMenuCallbacks(LLMenuGL* menu); | ||
116 | virtual void cut(); | 118 | virtual void cut(); |
117 | virtual BOOL canCut() const; | 119 | virtual BOOL canCut() const; |
118 | 120 | ||
@@ -152,11 +154,12 @@ public: | |||
152 | static void spell_show(void* data); | 154 | static void spell_show(void* data); |
153 | static void spell_add(void* data); | 155 | static void spell_add(void* data); |
154 | 156 | ||
155 | std::vector<S32> getMisspelledWordsPositions(); | 157 | void getMisspelledWordsPositions(std::vector<S32>& misspell_positions); |
158 | |||
156 | // view overrides | 159 | // view overrides |
157 | virtual void draw(); | 160 | virtual void draw(); |
158 | void autoCorrectText(); | 161 | void autoCorrectText(); |
159 | void drawMisspelled(LLRect background); | 162 | void drawMisspelled(const LLRect& background); |
160 | virtual void reshape(S32 width,S32 height,BOOL called_from_parent=TRUE); | 163 | virtual void reshape(S32 width,S32 height,BOOL called_from_parent=TRUE); |
161 | virtual void onFocusReceived(); | 164 | virtual void onFocusReceived(); |
162 | virtual void onFocusLost(); | 165 | virtual void onFocusLost(); |
@@ -303,7 +306,7 @@ protected: | |||
303 | std::string mPrevText; // Saved string for 'ESC' revert | 306 | std::string mPrevText; // Saved string for 'ESC' revert |
304 | LLUIString mLabel; // text label that is visible when no user text provided | 307 | LLUIString mLabel; // text label that is visible when no user text provided |
305 | std::string mPrevSpelledText; // saved string so we know whether to respell or not | 308 | std::string mPrevSpelledText; // saved string so we know whether to respell or not |
306 | std::vector<S32> misspellLocations; // where all the mispelled words are | 309 | std::vector<S32> mMisspellLocations; // where all the mispelled words are |
307 | S32 mStartSpellHere; // the position of the first char on the screen, stored so we know when to update | 310 | S32 mStartSpellHere; // the position of the first char on the screen, stored so we know when to update |
308 | S32 mEndSpellHere; // the location of the last char on the screen | 311 | S32 mEndSpellHere; // the location of the last char on the screen |
309 | BOOL mSpellCheckable; // set in xui as "spell_check". Default value for a field | 312 | BOOL mSpellCheckable; // set in xui as "spell_check". Default value for a field |
@@ -468,4 +471,6 @@ private: | |||
468 | 471 | ||
469 | }; | 472 | }; |
470 | 473 | ||
474 | |||
475 | |||
471 | #endif // LL_LINEEDITOR_ | 476 | #endif // LL_LINEEDITOR_ |
diff --git a/linden/indra/llui/llmenugl.cpp b/linden/indra/llui/llmenugl.cpp index 91bb581..d5e1186 100644 --- a/linden/indra/llui/llmenugl.cpp +++ b/linden/indra/llui/llmenugl.cpp | |||
@@ -149,6 +149,18 @@ LLMenuItemGL::LLMenuItemGL( const std::string& name, const std::string& label, K | |||
149 | setLabel( label ); | 149 | setLabel( label ); |
150 | } | 150 | } |
151 | 151 | ||
152 | LLMenuItemGL::~LLMenuItemGL() { | ||
153 | |||
154 | // Delete all the entries in the mFutureCallbackRequests vector | ||
155 | for(std::vector<LLCallbackInformation*>::iterator iter= mFutureCallbackRequests.begin(); | ||
156 | iter!=mFutureCallbackRequests.end(); | ||
157 | ++iter) { | ||
158 | delete (*iter); | ||
159 | } | ||
160 | |||
161 | } | ||
162 | |||
163 | |||
152 | // virtual | 164 | // virtual |
153 | LLXMLNodePtr LLMenuItemGL::getXML(bool save_children) const | 165 | LLXMLNodePtr LLMenuItemGL::getXML(bool save_children) const |
154 | { | 166 | { |
@@ -517,6 +529,18 @@ BOOL LLMenuItemGL::setLabelArg( const std::string& key, const LLStringExplicit& | |||
517 | return TRUE; | 529 | return TRUE; |
518 | } | 530 | } |
519 | 531 | ||
532 | |||
533 | void LLMenuItemGL::addCallbackType(U8 theType, | ||
534 | const std::string& name, | ||
535 | const std::string& userdata) { | ||
536 | |||
537 | // Add the new callback information to the list of callbacks that are being tracked. | ||
538 | mFutureCallbackRequests.push_back(new LLCallbackInformation(theType,name,userdata)); | ||
539 | |||
540 | } | ||
541 | |||
542 | |||
543 | |||
520 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 544 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
521 | // Class LLMenuItemSeparatorGL | 545 | // Class LLMenuItemSeparatorGL |
522 | // | 546 | // |
@@ -541,6 +565,12 @@ public: | |||
541 | virtual BOOL handleHover(S32 x, S32 y, MASK mask); | 565 | virtual BOOL handleHover(S32 x, S32 y, MASK mask); |
542 | 566 | ||
543 | virtual U32 getNominalHeight( void ) const { return SEPARATOR_HEIGHT_PIXELS; } | 567 | virtual U32 getNominalHeight( void ) const { return SEPARATOR_HEIGHT_PIXELS; } |
568 | |||
569 | virtual BOOL setCtrlResponse(U8 llMenuItemCallType, | ||
570 | const std::string& name, | ||
571 | void* user_data, | ||
572 | void *callback_fcn) { return FALSE; } ; | ||
573 | |||
544 | }; | 574 | }; |
545 | 575 | ||
546 | LLMenuItemSeparatorGL::LLMenuItemSeparatorGL( const std::string &name ) : | 576 | LLMenuItemSeparatorGL::LLMenuItemSeparatorGL( const std::string &name ) : |
@@ -726,6 +756,11 @@ public: | |||
726 | } | 756 | } |
727 | virtual void doIt( void ) {} | 757 | virtual void doIt( void ) {} |
728 | virtual void draw( void ) {} | 758 | virtual void draw( void ) {} |
759 | virtual BOOL setCtrlResponse(U8 llMenuItemCallType, | ||
760 | const std::string& name, | ||
761 | void* user_data, | ||
762 | void *callback_fcn) { return FALSE; } ; | ||
763 | |||
729 | }; | 764 | }; |
730 | 765 | ||
731 | 766 | ||
@@ -805,6 +840,8 @@ LLMenuItemCallGL::LLMenuItemCallGL(const std::string& name, | |||
805 | if(!enabled) setEnabled(FALSE); | 840 | if(!enabled) setEnabled(FALSE); |
806 | } | 841 | } |
807 | 842 | ||
843 | |||
844 | |||
808 | void LLMenuItemCallGL::setEnabledControl(std::string enabled_control, LLView *context) | 845 | void LLMenuItemCallGL::setEnabledControl(std::string enabled_control, LLView *context) |
809 | { | 846 | { |
810 | // Register new listener | 847 | // Register new listener |
@@ -921,6 +958,53 @@ BOOL LLMenuItemCallGL::handleAcceleratorKey( KEY key, MASK mask ) | |||
921 | return LLMenuItemGL::handleAcceleratorKey(key, mask); | 958 | return LLMenuItemGL::handleAcceleratorKey(key, mask); |
922 | } | 959 | } |
923 | 960 | ||
961 | |||
962 | |||
963 | // Method to add a callback function for the given type and name. | ||
964 | BOOL LLMenuItemCallGL::setCtrlResponse(U8 llMenuItemCallType, | ||
965 | const std::string& name, | ||
966 | void* user_data, | ||
967 | void *callback_fcn) { | ||
968 | |||
969 | // Loop through all of the menu items and check to see which ones | ||
970 | // match the name and callback type given. | ||
971 | BOOL result = FALSE; | ||
972 | std::vector<LLCallbackInformation*>::iterator item_iter; | ||
973 | for (item_iter = mFutureCallbackRequests.begin(); | ||
974 | item_iter != mFutureCallbackRequests.end(); | ||
975 | ++item_iter) | ||
976 | { | ||
977 | if( ((*item_iter)->getTypeOfCallback()==llMenuItemCallType) && | ||
978 | ((*item_iter)->getCallbackName()==name)) { | ||
979 | |||
980 | // Found a match. Set the user data and then determine what type it is. | ||
981 | setUserData(user_data); | ||
982 | |||
983 | if(llMenuItemCallType == LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_CLICK) | ||
984 | { | ||
985 | setMenuCallback((menu_callback)callback_fcn,user_data); | ||
986 | } | ||
987 | |||
988 | else if (llMenuItemCallType == LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_ENABLE) | ||
989 | { | ||
990 | setEnabledCallback((enabled_callback)callback_fcn); | ||
991 | } | ||
992 | |||
993 | else if (llMenuItemCallType == LLCallbackInformation::LL_MENU_ITEM_CALL_GL_TRANSLATE) { | ||
994 | setName((*item_iter)->getCallbackUserData()); | ||
995 | setMenuCallback((menu_callback)callback_fcn,user_data); | ||
996 | } | ||
997 | |||
998 | } | ||
999 | } | ||
1000 | |||
1001 | |||
1002 | return result; | ||
1003 | |||
1004 | } | ||
1005 | |||
1006 | |||
1007 | |||
924 | ///============================================================================ | 1008 | ///============================================================================ |
925 | /// Class LLMenuItemCheckGL | 1009 | /// Class LLMenuItemCheckGL |
926 | ///============================================================================ | 1010 | ///============================================================================ |
@@ -1379,6 +1463,17 @@ void LLMenuItemBranchGL::openMenu() | |||
1379 | } | 1463 | } |
1380 | 1464 | ||
1381 | 1465 | ||
1466 | BOOL LLMenuItemBranchGL::setCtrlResponse(U8 llMenuItemCallType, | ||
1467 | const std::string& name, | ||
1468 | void* user_data, | ||
1469 | void *callback_fcn) { | ||
1470 | |||
1471 | // Get the menu branch and set the callback functions on all its children. | ||
1472 | return(getBranch()->setCtrlResponse(llMenuItemCallType,name,user_data,callback_fcn)); | ||
1473 | |||
1474 | } | ||
1475 | |||
1476 | |||
1382 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 1477 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
1383 | // Class LLMenuItemBranchDownGL | 1478 | // Class LLMenuItemBranchDownGL |
1384 | // | 1479 | // |
@@ -1982,13 +2077,31 @@ void LLMenuGL::parseChildXML(LLXMLNodePtr child, LLView *parent, LLUICtrlFactory | |||
1982 | 2077 | ||
1983 | LLSimpleListener* callback = parent->getListenerByName(callback_name); | 2078 | LLSimpleListener* callback = parent->getListenerByName(callback_name); |
1984 | 2079 | ||
1985 | if (!callback) | 2080 | if (callback) |
1986 | { | 2081 | { |
1987 | lldebugs << "Ignoring \"on_click\" \"" << item_name << "\" because \"" << callback_name << "\" is not registered" << llendl; | 2082 | new_item->addListener(callback, "on_click", callback_data); |
1988 | continue; | 2083 | } |
2084 | else { | ||
2085 | |||
2086 | // A callback for this item has not yet been | ||
2087 | // specified. Add it to the list of options | ||
2088 | // that do not yet have callbacks. | ||
2089 | if (call_child->hasAttribute("translate")) | ||
2090 | { | ||
2091 | new_item->addCallbackType | ||
2092 | (LLCallbackInformation::LL_MENU_ITEM_CALL_GL_TRANSLATE, | ||
2093 | item_name, | ||
2094 | callback_data); | ||
2095 | } | ||
2096 | |||
2097 | else | ||
2098 | { | ||
2099 | new_item->addCallbackType | ||
2100 | (LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_CLICK, | ||
2101 | item_name, | ||
2102 | callback_data); | ||
2103 | } | ||
1989 | } | 2104 | } |
1990 | |||
1991 | new_item->addListener(callback, "on_click", callback_data); | ||
1992 | } | 2105 | } |
1993 | if (call_child->hasName("on_enable")) | 2106 | if (call_child->hasName("on_enable")) |
1994 | { | 2107 | { |
@@ -2016,13 +2129,22 @@ void LLMenuGL::parseChildXML(LLXMLNodePtr child, LLView *parent, LLUICtrlFactory | |||
2016 | 2129 | ||
2017 | LLSimpleListener* callback = parent->getListenerByName(callback_name); | 2130 | LLSimpleListener* callback = parent->getListenerByName(callback_name); |
2018 | 2131 | ||
2019 | if (!callback) | 2132 | if (callback) |
2020 | { | 2133 | { |
2021 | lldebugs << "Ignoring \"on_enable\" \"" << item_name << "\" because \"" << callback_name << "\" is not registered" << llendl; | 2134 | new_item->addListener(callback, "on_build", userdata); |
2022 | continue; | 2135 | } else { |
2136 | |||
2137 | // A callback for this item has not yet been | ||
2138 | // specified. Add it to the list of options | ||
2139 | // that do not yet have callbacks. | ||
2140 | |||
2141 | new_item->addCallbackType | ||
2142 | (LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_ENABLE, | ||
2143 | item_name, | ||
2144 | callback_data); | ||
2023 | } | 2145 | } |
2024 | 2146 | ||
2025 | new_item->addListener(callback, "on_build", userdata); | 2147 | |
2026 | } | 2148 | } |
2027 | else if (call_child->hasAttribute("control")) | 2149 | else if (call_child->hasAttribute("control")) |
2028 | { | 2150 | { |
@@ -2188,7 +2310,7 @@ LLView* LLMenuGL::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *fa | |||
2188 | LLColor4 color(0,0,0,1); | 2310 | LLColor4 color(0,0,0,1); |
2189 | if (opaque && LLUICtrlFactory::getAttributeColor(node,"color", color)) | 2311 | if (opaque && LLUICtrlFactory::getAttributeColor(node,"color", color)) |
2190 | { | 2312 | { |
2191 | menu->setBackgroundColor(color); | 2313 | menu->setBackgroundColor(color); |
2192 | } | 2314 | } |
2193 | 2315 | ||
2194 | BOOL create_jump_keys = FALSE; | 2316 | BOOL create_jump_keys = FALSE; |
@@ -2977,7 +3099,8 @@ void LLMenuGL::draw( void ) | |||
2977 | 3099 | ||
2978 | if( mBgVisible ) | 3100 | if( mBgVisible ) |
2979 | { | 3101 | { |
2980 | gl_rect_2d( 0, getRect().getHeight(), getRect().getWidth(), 0, mBackgroundColor ); | 3102 | gl_rect_2d( -1, getRect().getHeight()+2, getRect().getWidth()+2, -2, mBorderColor,FALSE); |
3103 | gl_rect_2d( 0, getRect().getHeight(), getRect().getWidth(), 0, mBackgroundColor ); | ||
2981 | } | 3104 | } |
2982 | LLView::draw(); | 3105 | LLView::draw(); |
2983 | } | 3106 | } |
@@ -3033,6 +3156,41 @@ LLMenuGL* LLMenuGL::getChildMenuByName(const std::string& name, BOOL recurse) co | |||
3033 | return NULL; | 3156 | return NULL; |
3034 | } | 3157 | } |
3035 | 3158 | ||
3159 | |||
3160 | void LLMenuGL::setBackgroundColor( const LLColor4& color ) { | ||
3161 | |||
3162 | mBackgroundColor = color; | ||
3163 | item_list_t::iterator item_iter; | ||
3164 | for (item_iter = mItems.begin(); item_iter != mItems.end(); ++item_iter) | ||
3165 | { | ||
3166 | if((*item_iter)->getType()=="menu") | ||
3167 | { | ||
3168 | LLMenuItemBranchGL *menuBranchItem = (LLMenuItemBranchGL*)(*item_iter); | ||
3169 | menuBranchItem->getBranch()->setBackgroundColor(color); | ||
3170 | } | ||
3171 | } | ||
3172 | |||
3173 | |||
3174 | } | ||
3175 | |||
3176 | |||
3177 | void LLMenuGL::setBorderColor( const LLColor4& color ) { | ||
3178 | |||
3179 | mBorderColor = color; | ||
3180 | item_list_t::iterator item_iter; | ||
3181 | for (item_iter = mItems.begin(); item_iter != mItems.end(); ++item_iter) | ||
3182 | { | ||
3183 | if((*item_iter)->getType()=="menu") | ||
3184 | { | ||
3185 | LLMenuItemBranchGL *menuBranchItem = (LLMenuItemBranchGL*)(*item_iter); | ||
3186 | menuBranchItem->getBranch()->setBorderColor(color); | ||
3187 | } | ||
3188 | } | ||
3189 | |||
3190 | |||
3191 | } | ||
3192 | |||
3193 | |||
3036 | BOOL LLMenuGL::clearHoverItem() | 3194 | BOOL LLMenuGL::clearHoverItem() |
3037 | { | 3195 | { |
3038 | for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it) | 3196 | for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it) |
@@ -3098,6 +3256,26 @@ void LLMenuGL::showPopup(LLView* spawning_view, LLMenuGL* menu, S32 x, S32 y) | |||
3098 | menu->getParent()->sendChildToFront(menu); | 3256 | menu->getParent()->sendChildToFront(menu); |
3099 | } | 3257 | } |
3100 | 3258 | ||
3259 | |||
3260 | BOOL LLMenuGL::setCtrlResponse(U8 llMenuItemCallType, | ||
3261 | const std::string& name, | ||
3262 | void* user_data, | ||
3263 | void *callback_fcn) | ||
3264 | { | ||
3265 | |||
3266 | // Go through all of the children on this menu and set the callback function. | ||
3267 | BOOL result = FALSE; | ||
3268 | item_list_t::iterator item_iter; | ||
3269 | for (item_iter = mItems.begin(); item_iter != mItems.end(); ++item_iter) | ||
3270 | { | ||
3271 | result |= (*item_iter)->setCtrlResponse(llMenuItemCallType,name,user_data,callback_fcn); | ||
3272 | } | ||
3273 | |||
3274 | return result; | ||
3275 | } | ||
3276 | |||
3277 | |||
3278 | |||
3101 | //----------------------------------------------------------------------------- | 3279 | //----------------------------------------------------------------------------- |
3102 | // class LLPieMenuBranch | 3280 | // class LLPieMenuBranch |
3103 | // A branch to another pie menu | 3281 | // A branch to another pie menu |
@@ -3117,6 +3295,12 @@ public: | |||
3117 | 3295 | ||
3118 | LLPieMenu* getBranch() { return mBranch; } | 3296 | LLPieMenu* getBranch() { return mBranch; } |
3119 | 3297 | ||
3298 | virtual BOOL setCtrlResponse(U8 llMenuItemCallType, | ||
3299 | const std::string& name, | ||
3300 | void* user_data, | ||
3301 | void *callback_fcn) { return FALSE; } ; | ||
3302 | |||
3303 | |||
3120 | protected: | 3304 | protected: |
3121 | LLPieMenu* mBranch; | 3305 | LLPieMenu* mBranch; |
3122 | }; | 3306 | }; |
@@ -4581,3 +4765,16 @@ void LLTearOffMenu::onClose(bool app_quitting) | |||
4581 | destroy(); | 4765 | destroy(); |
4582 | } | 4766 | } |
4583 | 4767 | ||
4768 | |||
4769 | ///============================================================================ | ||
4770 | /// Class LLCallbackInformation | ||
4771 | ///============================================================================ | ||
4772 | |||
4773 | LLCallbackInformation::LLCallbackInformation(U8 theType, | ||
4774 | const std::string& theName, | ||
4775 | const std::string& userData) | ||
4776 | : callbackName(theName), | ||
4777 | callbackUserData(userData) | ||
4778 | { | ||
4779 | setTypeOfCallback(theType); | ||
4780 | } | ||
diff --git a/linden/indra/llui/llmenugl.h b/linden/indra/llui/llmenugl.h index 63f9d55..9a9d1b0 100644 --- a/linden/indra/llui/llmenugl.h +++ b/linden/indra/llui/llmenugl.h | |||
@@ -70,6 +70,57 @@ typedef BOOL (*check_callback)(void*); | |||
70 | // contents. Put the contents of the label in the provided parameter. | 70 | // contents. Put the contents of the label in the provided parameter. |
71 | typedef void (*label_callback)(std::string&,void*); | 71 | typedef void (*label_callback)(std::string&,void*); |
72 | 72 | ||
73 | |||
74 | |||
75 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
76 | // Class LLCallbackInformation | ||
77 | // | ||
78 | // The LLCallbackInformation class is used to keep track of callback | ||
79 | // information for menus that might be requested at a future time. | ||
80 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
81 | |||
82 | class LLCallbackInformation | ||
83 | { | ||
84 | |||
85 | public : | ||
86 | |||
87 | // Constants used for keeping track of what type of callback is required. | ||
88 | static const U8 LL_MENU_ITEM_CALL_GL_NONE = 0; | ||
89 | static const U8 LL_MENU_ITEM_CALL_GL_ON_CLICK = 1; | ||
90 | static const U8 LL_MENU_ITEM_CALL_GL_ON_ENABLE = 2; | ||
91 | static const U8 LL_MENU_ITEM_CALL_GL_TRANSLATE = 3; | ||
92 | |||
93 | |||
94 | LLCallbackInformation(U8 theType=LLCallbackInformation::LL_MENU_ITEM_CALL_GL_NONE, | ||
95 | const std::string& theName = LLStringUtil::null, | ||
96 | const std::string& userData = LLStringUtil::null); | ||
97 | ~LLCallbackInformation() {}; | ||
98 | |||
99 | void setTypeOfCallback(U8 theType) {typeOfCallback = theType; } | ||
100 | void setCallbackName(const std::string& name) {callbackName = name; } | ||
101 | void setCallbackUserData(const std::string& userdata) {callbackUserData = userdata; } | ||
102 | |||
103 | U8 getTypeOfCallback() {return(typeOfCallback); } | ||
104 | const std::string& getCallbackName() {return(callbackName); } | ||
105 | const std::string& getCallbackUserData() {return(callbackUserData); } | ||
106 | |||
107 | BOOL isTypeMatch(U8 type) { return(type == typeOfCallback);} | ||
108 | BOOL isNameMatch(const std::string& name) { return(name == callbackName);} | ||
109 | |||
110 | protected: | ||
111 | |||
112 | private: | ||
113 | |||
114 | U8 typeOfCallback; | ||
115 | std::string callbackName; | ||
116 | std::string callbackUserData; | ||
117 | |||
118 | }; | ||
119 | |||
120 | |||
121 | |||
122 | |||
123 | |||
73 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 124 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
74 | // Class LLMenuItemGL | 125 | // Class LLMenuItemGL |
75 | // | 126 | // |
@@ -79,6 +130,7 @@ typedef void (*label_callback)(std::string&,void*); | |||
79 | class LLMenuItemGL : public LLView | 130 | class LLMenuItemGL : public LLView |
80 | { | 131 | { |
81 | public: | 132 | public: |
133 | |||
82 | // static functions to control the global color scheme. | 134 | // static functions to control the global color scheme. |
83 | static void setEnabledColor( const LLColor4& color ) { sEnabledColor = color; } | 135 | static void setEnabledColor( const LLColor4& color ) { sEnabledColor = color; } |
84 | static const LLColor4& getEnabledColor() { return sEnabledColor; } | 136 | static const LLColor4& getEnabledColor() { return sEnabledColor; } |
@@ -90,7 +142,7 @@ public: | |||
90 | static const LLColor4& getHighlightFGColor() { return sHighlightForeground; } | 142 | static const LLColor4& getHighlightFGColor() { return sHighlightForeground; } |
91 | 143 | ||
92 | LLMenuItemGL( const std::string& name, const std::string& label, KEY key = KEY_NONE, MASK = MASK_NONE ); | 144 | LLMenuItemGL( const std::string& name, const std::string& label, KEY key = KEY_NONE, MASK = MASK_NONE ); |
93 | virtual ~LLMenuItemGL() {}; | 145 | virtual ~LLMenuItemGL(); |
94 | 146 | ||
95 | virtual void setValue(const LLSD& value) { setLabel(value.asString()); } | 147 | virtual void setValue(const LLSD& value) { setLabel(value.asString()); } |
96 | 148 | ||
@@ -174,6 +226,14 @@ public: | |||
174 | void setDrawTextDisabled(BOOL disabled) { mDrawTextDisabled = disabled; } | 226 | void setDrawTextDisabled(BOOL disabled) { mDrawTextDisabled = disabled; } |
175 | BOOL getDrawTextDisabled() const { return mDrawTextDisabled; } | 227 | BOOL getDrawTextDisabled() const { return mDrawTextDisabled; } |
176 | 228 | ||
229 | // functionality for adding callbacks after the menu is constucted | ||
230 | void addCallbackType(U8 theType,const std::string& name,const std::string& userdata); | ||
231 | |||
232 | virtual BOOL setCtrlResponse(U8 llMenuItemCallType, | ||
233 | const std::string& name, | ||
234 | void* user_data, | ||
235 | void *callback_fcn) = 0; | ||
236 | |||
177 | protected: | 237 | protected: |
178 | void setHover(BOOL hover) { mGotHover = hover; } | 238 | void setHover(BOOL hover) { mGotHover = hover; } |
179 | 239 | ||
@@ -194,6 +254,11 @@ protected: | |||
194 | LLUIString mDrawBranchLabel; | 254 | LLUIString mDrawBranchLabel; |
195 | 255 | ||
196 | BOOL mHighlight; | 256 | BOOL mHighlight; |
257 | |||
258 | // variables used for tracking callback types that will be | ||
259 | // requested after the widget is in place. | ||
260 | std::vector<LLCallbackInformation*> mFutureCallbackRequests; | ||
261 | |||
197 | private: | 262 | private: |
198 | static LLColor4 sEnabledColor; | 263 | static LLColor4 sEnabledColor; |
199 | static LLColor4 sDisabledColor; | 264 | static LLColor4 sDisabledColor; |
@@ -214,6 +279,7 @@ private: | |||
214 | BOOL mDrawTextDisabled; | 279 | BOOL mDrawTextDisabled; |
215 | 280 | ||
216 | KEY mJumpKey; | 281 | KEY mJumpKey; |
282 | |||
217 | }; | 283 | }; |
218 | 284 | ||
219 | 285 | ||
@@ -262,6 +328,7 @@ public: | |||
262 | KEY key = KEY_NONE, MASK mask = MASK_NONE, | 328 | KEY key = KEY_NONE, MASK mask = MASK_NONE, |
263 | BOOL enabled = TRUE, | 329 | BOOL enabled = TRUE, |
264 | on_disabled_callback on_disabled_c = NULL); | 330 | on_disabled_callback on_disabled_c = NULL); |
331 | |||
265 | virtual LLXMLNodePtr getXML(bool save_children = true) const; | 332 | virtual LLXMLNodePtr getXML(bool save_children = true) const; |
266 | 333 | ||
267 | virtual std::string getType() const { return "call"; } | 334 | virtual std::string getType() const { return "call"; } |
@@ -288,6 +355,13 @@ public: | |||
288 | 355 | ||
289 | //virtual void draw(); | 356 | //virtual void draw(); |
290 | 357 | ||
358 | // Functionality for tracking callback types for setting after widget is in place. | ||
359 | virtual BOOL setCtrlResponse(U8 llMenuItemCallType, | ||
360 | const std::string& name, | ||
361 | void* user_data, | ||
362 | void *callback_fcn); | ||
363 | |||
364 | |||
291 | 365 | ||
292 | private: | 366 | private: |
293 | menu_callback mCallback; | 367 | menu_callback mCallback; |
@@ -382,6 +456,12 @@ public: | |||
382 | // LLView Functionality | 456 | // LLView Functionality |
383 | //virtual void draw( void ); | 457 | //virtual void draw( void ); |
384 | 458 | ||
459 | virtual BOOL setCtrlResponse(U8 llMenuItemCallType, | ||
460 | const std::string& name, | ||
461 | void* user_data, | ||
462 | void *callback_fcn) { return FALSE; } ; | ||
463 | |||
464 | |||
385 | private: | 465 | private: |
386 | BOOL* mToggle; | 466 | BOOL* mToggle; |
387 | }; | 467 | }; |
@@ -434,8 +514,10 @@ public: | |||
434 | 514 | ||
435 | // background colors | 515 | // background colors |
436 | static void setDefaultBackgroundColor( const LLColor4& color ) { sDefaultBackgroundColor = color; } | 516 | static void setDefaultBackgroundColor( const LLColor4& color ) { sDefaultBackgroundColor = color; } |
437 | void setBackgroundColor( const LLColor4& color ) { mBackgroundColor = color; } | 517 | void setBackgroundColor( const LLColor4& color ); |
518 | void setBorderColor( const LLColor4& color ); | ||
438 | const LLColor4& getBackgroundColor() const { return mBackgroundColor; } | 519 | const LLColor4& getBackgroundColor() const { return mBackgroundColor; } |
520 | const LLColor4& getBorderColor() const { return mBorderColor; } | ||
439 | void setBackgroundVisible( BOOL b ) { mBgVisible = b; } | 521 | void setBackgroundVisible( BOOL b ) { mBgVisible = b; } |
440 | void setCanTearOff(BOOL tear_off, LLHandle<LLFloater> parent_floater_handle = LLHandle<LLFloater>()); | 522 | void setCanTearOff(BOOL tear_off, LLHandle<LLFloater> parent_floater_handle = LLHandle<LLFloater>()); |
441 | 523 | ||
@@ -525,6 +607,8 @@ public: | |||
525 | static BOOL getKeyboardMode() { return sKeyboardMode; } | 607 | static BOOL getKeyboardMode() { return sKeyboardMode; } |
526 | 608 | ||
527 | static class LLMenuHolderGL* sMenuContainer; | 609 | static class LLMenuHolderGL* sMenuContainer; |
610 | |||
611 | BOOL setCtrlResponse(U8 llMenuItemCallType,const std::string& name,void* user_data,void *callback_fcn); | ||
528 | 612 | ||
529 | protected: | 613 | protected: |
530 | void createSpilloverBranch(); | 614 | void createSpilloverBranch(); |
@@ -547,6 +631,7 @@ private: | |||
547 | static BOOL sKeyboardMode; | 631 | static BOOL sKeyboardMode; |
548 | 632 | ||
549 | LLColor4 mBackgroundColor; | 633 | LLColor4 mBackgroundColor; |
634 | LLColor4 mBorderColor; | ||
550 | BOOL mBgVisible; | 635 | BOOL mBgVisible; |
551 | LLMenuItemGL* mParentMenuItem; | 636 | LLMenuItemGL* mParentMenuItem; |
552 | LLUIString mLabel; | 637 | LLUIString mLabel; |
@@ -623,6 +708,12 @@ public: | |||
623 | 708 | ||
624 | virtual LLView* getChildView(const std::string& name, BOOL recurse = TRUE, BOOL create_if_missing = TRUE) const; | 709 | virtual LLView* getChildView(const std::string& name, BOOL recurse = TRUE, BOOL create_if_missing = TRUE) const; |
625 | 710 | ||
711 | virtual BOOL setCtrlResponse(U8 llMenuItemCallType, | ||
712 | const std::string& name, | ||
713 | void* user_data, | ||
714 | void *callback_fcn); | ||
715 | |||
716 | |||
626 | private: | 717 | private: |
627 | LLHandle<LLView> mBranch; | 718 | LLHandle<LLView> mBranch; |
628 | }; // end class LLMenuItemBranchGL | 719 | }; // end class LLMenuItemBranchGL |
@@ -668,6 +759,12 @@ public: | |||
668 | void show(S32 x, S32 y, BOOL mouse_down); | 759 | void show(S32 x, S32 y, BOOL mouse_down); |
669 | void hide(BOOL item_selected); | 760 | void hide(BOOL item_selected); |
670 | 761 | ||
762 | virtual BOOL setCtrlResponse(U8 llMenuItemCallType, | ||
763 | const std::string& name, | ||
764 | void* user_data, | ||
765 | void *callback_fcn) { return FALSE; } ; | ||
766 | |||
767 | |||
671 | private: | 768 | private: |
672 | LLMenuItemGL *pieItemFromXY(S32 x, S32 y); | 769 | LLMenuItemGL *pieItemFromXY(S32 x, S32 y); |
673 | S32 pieItemIndexFromXY(S32 x, S32 y); | 770 | S32 pieItemIndexFromXY(S32 x, S32 y); |
@@ -729,6 +826,12 @@ public: | |||
729 | 826 | ||
730 | void resetMenuTrigger() { mAltKeyTrigger = FALSE; } | 827 | void resetMenuTrigger() { mAltKeyTrigger = FALSE; } |
731 | 828 | ||
829 | virtual BOOL setCtrlResponse(U8 llMenuItemCallType, | ||
830 | const std::string& name, | ||
831 | void* user_data, | ||
832 | void *callback_fcn) { return FALSE; } ; | ||
833 | |||
834 | |||
732 | private: | 835 | private: |
733 | void checkMenuTrigger(); | 836 | void checkMenuTrigger(); |
734 | 837 | ||
@@ -814,6 +917,12 @@ public: | |||
814 | virtual void draw(void); | 917 | virtual void draw(void); |
815 | virtual U32 getNominalHeight() const; | 918 | virtual U32 getNominalHeight() const; |
816 | 919 | ||
920 | virtual BOOL setCtrlResponse(U8 llMenuItemCallType, | ||
921 | const std::string& name, | ||
922 | void* user_data, | ||
923 | void *callback_fcn) { return FALSE; } ; | ||
924 | |||
925 | |||
817 | private: | 926 | private: |
818 | LLHandle<LLFloater> mParentHandle; | 927 | LLHandle<LLFloater> mParentHandle; |
819 | }; | 928 | }; |
@@ -832,4 +941,5 @@ private: | |||
832 | LLEditMenuHandlerMgr() {}; | 941 | LLEditMenuHandlerMgr() {}; |
833 | }; | 942 | }; |
834 | 943 | ||
944 | |||
835 | #endif // LL_LLMENUGL_H | 945 | #endif // LL_LLMENUGL_H |
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 | ||
427 | LLTextEditor::~LLTextEditor() | 402 | LLTextEditor::~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 | ||
533 | std::vector<S32> LLTextEditor::getMisspelledWordsPositions() | 508 | void 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 | |||
572 | void LLTextEditor::spell_add(void* data) | 550 | void 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 | ||
597 | void 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 | |||
618 | void LLTextEditor::setTrackColor( const LLColor4& color ) | 658 | void 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(); |
diff --git a/linden/indra/llui/lltexteditor.h b/linden/indra/llui/lltexteditor.h index f2a831b..759cd69 100644 --- a/linden/indra/llui/lltexteditor.h +++ b/linden/indra/llui/lltexteditor.h | |||
@@ -166,7 +166,10 @@ public: | |||
166 | static void spell_correct(void* data); | 166 | static void spell_correct(void* data); |
167 | static void spell_add(void* data); | 167 | static void spell_add(void* data); |
168 | static void spell_show(void* data); | 168 | static void spell_show(void* data); |
169 | std::vector<S32> getMisspelledWordsPositions(); | 169 | |
170 | void getMisspelledWordsPositions(std::vector<S32>& misspell_positions); | ||
171 | |||
172 | void defineMenuCallbacks(LLMenuGL* menu); | ||
170 | 173 | ||
171 | void selectNext(const std::string& search_text_in, BOOL case_insensitive, BOOL wrap = TRUE); | 174 | void selectNext(const std::string& search_text_in, BOOL case_insensitive, BOOL wrap = TRUE); |
172 | BOOL replaceText(const std::string& search_text, const std::string& replace_text, BOOL case_insensitive, BOOL wrap = TRUE); | 175 | BOOL replaceText(const std::string& search_text, const std::string& replace_text, BOOL case_insensitive, BOOL wrap = TRUE); |
@@ -534,7 +537,7 @@ private: | |||
534 | LLWString mPrevSpelledText; // saved string so we know whether to respell or not | 537 | LLWString mPrevSpelledText; // saved string so we know whether to respell or not |
535 | S32 spellStart; | 538 | S32 spellStart; |
536 | S32 spellEnd; | 539 | S32 spellEnd; |
537 | std::vector<S32> misspellLocations; // where all the mispelled words are | 540 | std::vector<S32> mMisspellLocations; // where all the mispelled words are |
538 | BOOL mSpellCheckable; // set in xui as "spell_check". Default value for a field | 541 | BOOL mSpellCheckable; // set in xui as "spell_check". Default value for a field |
539 | BOOL mAllowTranslate; // set in xui as "allow_translate". | 542 | BOOL mAllowTranslate; // set in xui as "allow_translate". |
540 | 543 | ||