aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llfloatersearchreplace.cpp
diff options
context:
space:
mode:
authorMcCabe Maxsted2010-03-04 13:16:28 -0700
committerJacek Antonelli2010-03-11 19:03:52 -0600
commit1ddfb4c5dd436fc1a9a867d0a2b9980483a3d3fd (patch)
tree4ce9ece8150a60ab7292bd6cef3ff3c0dfcc4025 /linden/indra/newview/llfloatersearchreplace.cpp
parentApplied UnknownJointsCrashFix v2 from Cool Viewer. (diff)
downloadmeta-impy-1ddfb4c5dd436fc1a9a867d0a2b9980483a3d3fd.zip
meta-impy-1ddfb4c5dd436fc1a9a867d0a2b9980483a3d3fd.tar.gz
meta-impy-1ddfb4c5dd436fc1a9a867d0a2b9980483a3d3fd.tar.bz2
meta-impy-1ddfb4c5dd436fc1a9a867d0a2b9980483a3d3fd.tar.xz
Applied Kitty Barnett's patch for Search/Replace in notecards.
Diffstat (limited to 'linden/indra/newview/llfloatersearchreplace.cpp')
-rw-r--r--linden/indra/newview/llfloatersearchreplace.cpp114
1 files changed, 114 insertions, 0 deletions
diff --git a/linden/indra/newview/llfloatersearchreplace.cpp b/linden/indra/newview/llfloatersearchreplace.cpp
new file mode 100644
index 0000000..a339a54
--- /dev/null
+++ b/linden/indra/newview/llfloatersearchreplace.cpp
@@ -0,0 +1,114 @@
1#include "llviewerprecompiledheaders.h"
2#include "llcheckboxctrl.h"
3#include "llfocusmgr.h"
4#include "lluictrlfactory.h"
5
6#include "llfloatersearchreplace.h"
7
8const S32 SEARCH_REPLACE_WIDTH = 300;
9const S32 SEARCH_REPLACE_HEIGHT = 120;
10const std::string SEARCH_REPLACE_TITLE = "Search and Replace";
11
12LLFloaterSearchReplace* LLFloaterSearchReplace::sInstance = NULL;
13
14LLFloaterSearchReplace::LLFloaterSearchReplace() : mEditor(NULL),
15 LLFloater(std::string("searchreplace"), LLRect(0, 0, SEARCH_REPLACE_WIDTH, SEARCH_REPLACE_HEIGHT), SEARCH_REPLACE_TITLE)
16{
17 LLUICtrlFactory::getInstance()->buildFloater(this, "floater_search_replace.xml");
18}
19
20LLFloaterSearchReplace::~LLFloaterSearchReplace()
21{
22 sInstance = NULL;
23}
24
25void LLFloaterSearchReplace::open()
26{
27 LLFloater::open();
28
29 if (mEditor)
30 {
31 bool fReadOnly = mEditor->isReadOnly();
32 childSetEnabled("replace_label", !fReadOnly);
33 childSetEnabled("replace_text", !fReadOnly);
34 childSetEnabled("replace_btn", !fReadOnly);
35 childSetEnabled("replace_all_btn", !fReadOnly);
36 }
37
38 childSetFocus("search_text", TRUE);
39}
40
41BOOL LLFloaterSearchReplace::postBuild()
42{
43 childSetAction("search_btn", onBtnSearch, this);
44 childSetAction("replace_btn", onBtnReplace, this);
45 childSetAction("replace_all_btn", onBtnReplaceAll, this);
46
47 setDefaultBtn("search_btn");
48
49 return TRUE;
50}
51
52void LLFloaterSearchReplace::show(LLTextEditor* editor)
53{
54 if (!sInstance)
55 {
56 sInstance = new LLFloaterSearchReplace();
57 }
58
59 if ( (sInstance) && (editor) )
60 {
61 sInstance->mEditor = editor;
62
63 LLFloater* newdependee, *olddependee = sInstance->getDependee();
64 LLView* viewp = editor->getParent();
65 while (viewp)
66 {
67 newdependee = dynamic_cast<LLFloater*>(viewp);
68 if (newdependee)
69 {
70 if (newdependee != olddependee)
71 {
72 if (olddependee)
73 olddependee->removeDependentFloater(sInstance);
74
75 if (!newdependee->getHost())
76 newdependee->addDependentFloater(sInstance);
77 else
78 newdependee->getHost()->addDependentFloater(sInstance);
79 }
80 break;
81 }
82 viewp = viewp->getParent();
83 }
84
85 sInstance->open();
86 }
87}
88
89void LLFloaterSearchReplace::onBtnSearch(void* userdata)
90{
91 if ( (!sInstance) || (!sInstance->mEditor) || (!sInstance->getDependee()) )
92 return;
93
94 LLCheckBoxCtrl* caseChk = sInstance->getChild<LLCheckBoxCtrl>("case_text");
95 sInstance->mEditor->selectNext(sInstance->childGetText("search_text"), caseChk->get());
96}
97
98void LLFloaterSearchReplace::onBtnReplace(void* userdata)
99{
100 if ( (!sInstance) || (!sInstance->mEditor) || (!sInstance->getDependee()) )
101 return;
102
103 LLCheckBoxCtrl* caseChk = sInstance->getChild<LLCheckBoxCtrl>("case_text");
104 sInstance->mEditor->replaceText(sInstance->childGetText("search_text"), sInstance->childGetText("replace_text"), caseChk->get());
105}
106
107void LLFloaterSearchReplace::onBtnReplaceAll(void* userdata)
108{
109 if ( (!sInstance) || (!sInstance->mEditor) || (!sInstance->getDependee()) )
110 return;
111
112 LLCheckBoxCtrl* caseChk = sInstance->getChild<LLCheckBoxCtrl>("case_text");
113 sInstance->mEditor->replaceTextAll(sInstance->childGetText("search_text"), sInstance->childGetText("replace_text"), caseChk->get());
114}