TDME2  1.9.200
FindReplaceDialogScreenController.cpp
Go to the documentation of this file.
2 
3 #include <string>
4 
5 #include <tdme/tdme.h>
7 #include <tdme/engine/Engine.h>
8 #include <tdme/engine/Version.h>
17 #include <tdme/gui/GUI.h>
18 #include <tdme/gui/GUIParser.h>
21 #include <tdme/utilities/Action.h>
22 #include <tdme/utilities/Console.h>
26 
27 using std::string;
28 
30 
42 using tdme::gui::GUI;
51 
52 FindReplaceDialogScreenController::FindReplaceDialogScreenController(PopUps* popUps): popUps(popUps)
53 {
54 }
55 
57 {
58 }
59 
61 {
62  return screenNode;
63 }
64 
66 {
67  try {
68  screenNode = GUIParser::parse("resources/engine/gui", "popup_findreplace.xml");
69  screenNode->setEnabled(false);
73  findText = required_dynamic_cast<GUIElementNode*>(screenNode->getNodeById("findreplace_findtext"));
74  replaceText = required_dynamic_cast<GUIElementNode*>(screenNode->getNodeById("findreplace_replacetext"));
75  matchCase = required_dynamic_cast<GUIElementNode*>(screenNode->getNodeById("findreplace_matchcase"));
76  wholeWordOnly = required_dynamic_cast<GUIElementNode*>(screenNode->getNodeById("findreplace_wholewordonly"));
77  inSelectionOnly = required_dynamic_cast<GUIElementNode*>(screenNode->getNodeById("findreplace_inselectiononly"));
78  findButton = required_dynamic_cast<GUIElementNode*>(screenNode->getNodeById("findreplace_find"));
79  countButton = required_dynamic_cast<GUIElementNode*>(screenNode->getNodeById("findreplace_count"));
80  cancelButton = required_dynamic_cast<GUIElementNode*>(screenNode->getNodeById("findreplace_cancel"));
81  replaceButton = required_dynamic_cast<GUIElementNode*>(screenNode->getNodeById("findreplace_replace"));
82  replaceAllButton = required_dynamic_cast<GUIElementNode*>(screenNode->getNodeById("findreplace_replaceall"));
83  } catch (Exception& exception) {
84  Console::println("FindReplaceDialogScreenController::initialize(): An error occurred: " + string(exception.what()));
85  }
86 }
87 
89 {
90 }
91 
94 }
95 
98 }
99 
101  return matchCase->getController()->getValue().equals("1");
102 }
103 
105  return wholeWordOnly->getController()->getValue().equals("1");
106 }
107 
109  return inSelectionOnly->getController()->getValue().equals("1");
110 }
111 
112 void FindReplaceDialogScreenController::show(Action* findAction, Action* countAction, Action* replaceAction, Action* replaceAllAction, Action* completeAction)
113 {
114  this->findAction = unique_ptr<Action>(findAction);
115  this->countAction = unique_ptr<Action>(countAction);
116  this->replaceAction = unique_ptr<Action>(replaceAction);
117  this->replaceAllAction = unique_ptr<Action>(replaceAllAction);
118  this->completeAction = unique_ptr<Action>(completeAction);
119  //
120  screenNode->setEnabled(true);
121  Engine::getInstance()->getGUI()->setFoccussedNode(findText);
122 }
123 
125 {
126  screenNode->setEnabled(false);
127  findAction = nullptr;
128  countAction = nullptr;
129  replaceAction = nullptr;
130  replaceAllAction = nullptr;
131  completeAction = nullptr;
132 }
133 
135 {
136  if (type == GUIActionListenerType::PERFORMED) {
137  if (StringTools::startsWith(node->getId(), "findreplace_caption_close_") == true) { // TODO: a.drewke, check with DH) {
138  if (completeAction != nullptr) completeAction->performAction();
139  } else
140  if (node->getId() == findButton->getId()) {
141  if (findAction != nullptr) findAction->performAction();
142  } else
143  if (node->getId() == countButton->getId()) {
144  if (countAction != nullptr) countAction->performAction();
145  } else
146  if (node->getId() == replaceButton->getId()) {
147  if (replaceAction != nullptr) replaceAction->performAction();
148  } else
149  if (node->getId() == replaceAllButton->getId()) {
150  if (replaceAllAction != nullptr) replaceAllAction->performAction();
151  } else
152  if (node->getId() == cancelButton->getId()) {
153  if (completeAction != nullptr) completeAction->performAction();
154  }
155  }
156 }
157 
159  GUI::setDisableTabFocusControl(node->getScreenNode() != screenNode);
160 }
161 
163 }
164 
166  popUps->getTooltipScreenController()->show(mouseX, mouseY, node->getToolTip());
167 }
168 
171 }
Application base class, please make sure to allocate application on heap to have correct application ...
Definition: Application.h:41
Engine main class.
Definition: Engine.h:131
GUI parser.
Definition: GUIParser.h:40
GUI module class.
Definition: GUI.h:64
GUI node controller base class.
virtual const MutableString & getValue()=0
GUI node base class.
Definition: GUINode.h:64
const string & getToolTip()
Definition: GUINode.h:346
GUINodeController * getController()
Definition: GUINode.h:661
GUIScreenNode * getScreenNode()
Definition: GUINode.h:325
const string & getId()
Definition: GUINode.h:339
GUI screen node that represents a screen that can be rendered via GUI system.
Definition: GUIScreenNode.h:72
void setEnabled(bool enabled)
Set enabled.
void addTooltipRequestListener(GUITooltipRequestListener *listener)
Add tooltip request listener.
void addActionListener(GUIActionListener *listener)
Add action listener.
void addFocusListener(GUIFocusListener *listener)
Add focus listener.
GUINode * getNodeById(const string &nodeId)
Get GUI node by id.
void show(Action *findAction, Action *countAction, Action *replaceAction, Action *replaceAllAction, Action *completeAction)
Shows the pop up.
void onAction(GUIActionListenerType type, GUIElementNode *node) override
void onTooltipShowRequest(GUINode *node, int mouseX, int mouseY) override
On tooltip show request.
void show(int mouseX, int mouseY, const string &tooltip)
Show tooltip.
Pop ups controller accessor class.
Definition: PopUps.h:29
TooltipScreenController * getTooltipScreenController()
Definition: PopUps.h:131
Console class.
Definition: Console.h:29
Mutable utf8 aware string class.
Definition: MutableString.h:23
bool equals(const string &s2) const
Equals.
const string & getString() const
String tools class.
Definition: StringTools.h:22
std::exception Exception
Exception base class.
Definition: Exception.h:18
GUI focus listener interface.
Action Interface.
Definition: Action.h:11