PageRenderTime 43ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/newview/lltoastscripttextbox.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 121 lines | 69 code | 21 blank | 31 comment | 3 complexity | a94dc456a1e1e3f500130e717a758d70 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file lltoastscripttextbox.cpp
  3. * @brief Panel for script llTextBox dialogs
  4. *
  5. * $LicenseInfo:firstyear=2001&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #include "llviewerprecompiledheaders.h"
  27. #include "lltoastscripttextbox.h"
  28. #include "llfocusmgr.h"
  29. #include "llbutton.h"
  30. #include "llnotifications.h"
  31. #include "llviewertexteditor.h"
  32. #include "llavatarnamecache.h"
  33. #include "lluiconstants.h"
  34. #include "llui.h"
  35. #include "llviewercontrol.h"
  36. #include "lltrans.h"
  37. #include "llstyle.h"
  38. #include "llglheaders.h"
  39. #include "llagent.h"
  40. const S32 LLToastScriptTextbox::DEFAULT_MESSAGE_MAX_LINE_COUNT= 7;
  41. LLToastScriptTextbox::LLToastScriptTextbox(const LLNotificationPtr& notification)
  42. : LLToastPanel(notification)
  43. {
  44. buildFromFile( "panel_notify_textbox.xml");
  45. LLTextEditor* text_editorp = getChild<LLTextEditor>("text_editor_box");
  46. text_editorp->setValue(notification->getMessage());
  47. getChild<LLButton>("ignore_btn")->setClickedCallback(boost::bind(&LLToastScriptTextbox::onClickIgnore, this));
  48. const LLSD& payload = notification->getPayload();
  49. //message body
  50. const std::string& message = payload["message"].asString();
  51. LLViewerTextEditor* pMessageText = getChild<LLViewerTextEditor>("message");
  52. pMessageText->clear();
  53. LLStyle::Params style;
  54. style.font = pMessageText->getDefaultFont();
  55. pMessageText->appendText(message, TRUE, style);
  56. //submit button
  57. LLButton* pSubmitBtn = getChild<LLButton>("btn_submit");
  58. pSubmitBtn->setClickedCallback((boost::bind(&LLToastScriptTextbox::onClickSubmit, this)));
  59. setDefaultBtn(pSubmitBtn);
  60. S32 maxLinesCount;
  61. std::istringstream ss( getString("message_max_lines_count") );
  62. if (!(ss >> maxLinesCount))
  63. {
  64. maxLinesCount = DEFAULT_MESSAGE_MAX_LINE_COUNT;
  65. }
  66. //snapToMessageHeight(pMessageText, maxLinesCount);
  67. }
  68. // virtual
  69. LLToastScriptTextbox::~LLToastScriptTextbox()
  70. {
  71. }
  72. void LLToastScriptTextbox::close()
  73. {
  74. die();
  75. }
  76. #include "lllslconstants.h"
  77. void LLToastScriptTextbox::onClickSubmit()
  78. {
  79. LLViewerTextEditor* pMessageText = getChild<LLViewerTextEditor>("message");
  80. if (pMessageText)
  81. {
  82. LLSD response = mNotification->getResponseTemplate();
  83. response[TEXTBOX_MAGIC_TOKEN] = pMessageText->getText();
  84. if (response[TEXTBOX_MAGIC_TOKEN].asString().empty())
  85. {
  86. // so we can distinguish between a successfully
  87. // submitted blank textbox, and an ignored toast
  88. response[TEXTBOX_MAGIC_TOKEN] = true;
  89. }
  90. mNotification->respond(response);
  91. close();
  92. llwarns << response << llendl;
  93. }
  94. }
  95. void LLToastScriptTextbox::onClickIgnore()
  96. {
  97. LLSD response = mNotification->getResponseTemplate();
  98. mNotification->respond(response);
  99. close();
  100. }