PageRenderTime 50ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/newview/lltoastnotifypanel.h

https://bitbucket.org/lindenlab/viewer-beta/
C Header | 150 lines | 64 code | 24 blank | 62 comment | 0 complexity | 8001604876d47c9a803a970205ba6c78 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file lltoastnotifypanel.h
  3. * @brief Panel for notify toasts.
  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. #ifndef LLTOASTNOTIFYPANEL_H_
  27. #define LLTOASTNOTIFYPANEL_H_
  28. #include "llpanel.h"
  29. #include "llfontgl.h"
  30. #include "llnotificationptr.h"
  31. #include "llbutton.h"
  32. #include "lltoastpanel.h"
  33. #include "lliconctrl.h"
  34. #include "lltexteditor.h"
  35. #include "lltextbox.h"
  36. class LLNotificationForm;
  37. /**
  38. * Toast panel for notification.
  39. * Notification panel should be used for notifications that require a response from the user.
  40. *
  41. * Replaces class LLNotifyBox.
  42. *
  43. * @deprecated this class will be removed after all toast panel types are
  44. * implemented in separate classes.
  45. */
  46. class LLToastNotifyPanel: public LLToastPanel
  47. {
  48. public:
  49. /**
  50. * Constructor for LLToastNotifyPanel.
  51. *
  52. * @param pNotification a shared pointer to LLNotification
  53. * @param rect an initial rectangle of the toast panel.
  54. * If it is null then a loaded from xml rectangle will be used.
  55. * @see LLNotification
  56. * @deprecated if you intend to instantiate LLToastNotifyPanel - it's point to
  57. * implement right class for desired toast panel. @see LLGenericTipPanel as example.
  58. */
  59. LLToastNotifyPanel(LLNotificationPtr& pNotification, const LLRect& rect = LLRect::null, bool show_images = true);
  60. virtual ~LLToastNotifyPanel();
  61. LLPanel * getControlPanel() { return mControlPanel; }
  62. void setCloseNotificationOnDestroy(bool close) { mCloseNotificationOnDestroy = close; }
  63. protected:
  64. LLButton* createButton(const LLSD& form_element, BOOL is_option);
  65. // Used for callbacks
  66. struct InstanceAndS32
  67. {
  68. LLToastNotifyPanel* mSelf;
  69. std::string mButtonName;
  70. };
  71. std::vector<InstanceAndS32*> mBtnCallbackData;
  72. bool mCloseNotificationOnDestroy;
  73. typedef std::pair<int,LLButton*> index_button_pair_t;
  74. void adjustPanelForScriptNotice(S32 max_width, S32 max_height);
  75. void adjustPanelForTipNotice();
  76. void addDefaultButton();
  77. /*
  78. * It lays out buttons of the notification in mControlPanel.
  79. * Buttons will be placed from BOTTOM to TOP.
  80. * @param h_pad horizontal space between buttons. It is depend on number of buttons.
  81. * @param buttons vector of button to be added.
  82. */
  83. void updateButtonsLayout(const std::vector<index_button_pair_t>& buttons, S32 h_pad);
  84. /**
  85. * Disable specific button(s) based on notification name and clicked button
  86. */
  87. void disableButtons(const std::string& notification_name, const std::string& selected_button);
  88. std::vector<index_button_pair_t> mButtons;
  89. // panel elements
  90. LLTextBase* mTextBox;
  91. LLPanel* mInfoPanel; // a panel, that contains an information
  92. LLPanel* mControlPanel; // a panel, that contains buttons (if present)
  93. // internal handler for button being clicked
  94. static void onClickButton(void* data);
  95. typedef boost::signals2::signal <void (const LLUUID& notification_id, const std::string btn_name)>
  96. button_click_signal_t;
  97. static button_click_signal_t sButtonClickSignal;
  98. boost::signals2::connection mButtonClickConnection;
  99. /**
  100. * handle sButtonClickSignal (to disable buttons) across all panels with given notification_id
  101. */
  102. void onToastPanelButtonClicked(const LLUUID& notification_id, const std::string btn_name);
  103. /**
  104. * Process response data. Will disable selected options
  105. */
  106. void disableRespondedOptions(LLNotificationPtr& notification);
  107. bool mIsTip;
  108. bool mAddedDefaultBtn;
  109. bool mIsScriptDialog;
  110. bool mIsCaution;
  111. std::string mMessage;
  112. S32 mNumOptions;
  113. S32 mNumButtons;
  114. static const LLFontGL* sFont;
  115. static const LLFontGL* sFontSmall;
  116. };
  117. class LLIMToastNotifyPanel : public LLToastNotifyPanel
  118. {
  119. public:
  120. LLIMToastNotifyPanel(LLNotificationPtr& pNotification, const LLUUID& session_id, const LLRect& rect = LLRect::null, bool show_images = true);
  121. ~LLIMToastNotifyPanel();
  122. /*virtual*/ void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
  123. protected:
  124. LLUUID mSessionID;
  125. };
  126. #endif /* LLTOASTNOTIFYPANEL_H_ */