PageRenderTime 17ms CodeModel.GetById 5ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 1ms

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