TDME2  1.9.200
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
InfoDialogScreenController.cpp
Go to the documentation of this file.
2 
3 #include <string>
4 
5 #include <tdme/tdme.h>
12 #include <tdme/gui/GUI.h>
13 #include <tdme/gui/GUIParser.h>
16 #include <tdme/utilities/Console.h>
20 
21 using std::string;
22 
24 
38 
39 InfoDialogScreenController::InfoDialogScreenController(PopUps* popUps): popUps(popUps)
40 {
41 }
42 
44 {
45  screenNode = nullptr;
46 }
47 
49 {
50  return screenNode;
51 }
52 
54 {
55  try {
56  screenNode = GUIParser::parse("resources/engine/gui", "popup_infodialog.xml");
57  screenNode->setEnabled(false);
60  tabsHeaderNode = required_dynamic_cast<GUIElementNode*>(screenNode->getNodeById("infodialog_tabs-header"));
61  messageNode = dynamic_cast<GUIStyledTextNode*>(screenNode->getNodeById("infodialog_message"));
62  } catch (Exception& exception) {
63  Console::println("InfoDialogScreenController::initialize(): An error occurred: " + string(exception.what()));
64  }
65 }
66 
68 {
69 }
70 
71 void InfoDialogScreenController::show(const string& caption, const string& message)
72 {
73  screenNode->setEnabled(true);
74  required_dynamic_cast<GUIParentNode*>(screenNode->getInnerNodeById(tabsHeaderNode->getId()))->replaceSubNodes("<tab id=\"infodialog_caption\" image=\"resources/engine/images/attention.png\" text=\"" + caption + "\" closeable=\"true\"/>", true);
75  messageNode->setText(message);
76 }
77 
79 {
80  screenNode->setEnabled(false);
81 }
82 
84 {
86  if (node->getId() == "infodialog_button1" ||
87  StringTools::startsWith(node->getId(), "infodialog_caption_close_") == true) { // TODO: a.drewke, check with DH) {
88  close();
89  }
90  }
91 }
92 
94  GUI::setDisableTabFocusControl(node->getScreenNode() != screenNode);
95 }
96 
98 }
99 
100 void InfoDialogScreenController::onTooltipShowRequest(GUINode* node, int mouseX, int mouseY) {
101  popUps->getTooltipScreenController()->show(mouseX, mouseY, node->getToolTip());
102 }
103 
106 }
GUI parser.
Definition: GUIParser.h:40
GUI node base class.
Definition: GUINode.h:64
const string & getToolTip()
Definition: GUINode.h:346
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.
GUINode * getInnerNodeById(const string &nodeId)
Get inner GUI node by id.
GUINode * getNodeById(const string &nodeId)
Get GUI node by id.
void setText(const MutableString &text)
Set text.
void show(const string &caption, const string &message)
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
String tools class.
Definition: StringTools.h:22
std::exception Exception
Exception base class.
Definition: Exception.h:18