aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llnotify.h
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:46 -0500
committerJacek Antonelli2008-08-15 23:44:46 -0500
commit38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch)
treeadca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/llnotify.h
parentREADME.txt (diff)
downloadmeta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/newview/llnotify.h')
-rw-r--r--linden/indra/newview/llnotify.h168
1 files changed, 168 insertions, 0 deletions
diff --git a/linden/indra/newview/llnotify.h b/linden/indra/newview/llnotify.h
new file mode 100644
index 0000000..cddcc42
--- /dev/null
+++ b/linden/indra/newview/llnotify.h
@@ -0,0 +1,168 @@
1/**
2 * @file llnotify.h
3 * @brief Non-blocking notification that doesn't take keyboard focus.
4 *
5 * Copyright (c) 2003-2007, Linden Research, Inc.
6 *
7 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement
10 * ("Other License"), formally executed by you and Linden Lab. Terms of
11 * the GPL can be found in doc/GPL-license.txt in this distribution, or
12 * online at http://secondlife.com/developers/opensource/gplv2
13 *
14 * There are special exceptions to the terms and conditions of the GPL as
15 * it is applied to this Source Code. View the full text of the exception
16 * in the file doc/FLOSS-exception.txt in this software distribution, or
17 * online at http://secondlife.com/developers/opensource/flossexception
18 *
19 * By copying, modifying or distributing this software, you acknowledge
20 * that you have read and understood your obligations described above,
21 * and agree to abide by those obligations.
22 *
23 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
24 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
25 * COMPLETENESS OR PERFORMANCE.
26 */
27
28#ifndef LL_LLNOTIFY_H
29#define LL_LLNOTIFY_H
30
31#include "llfontgl.h"
32#include "llpanel.h"
33#include "lldarray.h"
34#include "lltimer.h"
35
36class LLButton;
37class LLNotifyBoxTemplate;
38
39// NotifyBox - for notifications that require a response from the user.
40class LLNotifyBox : public LLPanel, public LLEventTimer
41{
42public:
43 typedef void (*notify_callback_t)(S32 option, void* data);
44 typedef std::vector<LLString> option_list_t;
45
46 static void showXml( const LLString& xml_desc,
47 notify_callback_t callback = NULL, void *user_data = NULL);
48
49 static void showXml( const LLString& xml_desc, const LLString::format_map_t& args,
50 notify_callback_t callback = NULL, void *user_data = NULL);
51 // For script notifications:
52 static void showXml( const LLString& xml_desc, const LLString::format_map_t& args,
53 notify_callback_t callback, void *user_data,
54 const option_list_t& options,
55 BOOL layout_script_dialog = FALSE);
56
57 static bool parseNotify(const LLString& xml_filename);
58 static const LLString& getTemplateMessage(const LLString& xml_desc);
59
60 BOOL isTip() const { return mIsTip; }
61 /*virtual*/ void setVisible(BOOL visible);
62
63protected:
64 LLNotifyBox(const LLString& xml_desc, const LLString::format_map_t& args,
65 notify_callback_t callback, void* user_data,
66 const option_list_t& extra_options = option_list_t(),
67 BOOL layout_script_dialog = FALSE);
68 /*virtual*/ ~LLNotifyBox();
69
70
71 /*virtual*/ BOOL handleMouseUp(S32 x, S32 y, MASK mask);
72 /*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
73
74 // Animate as sliding onto the screen.
75 /*virtual*/ void draw();
76 /*virtual*/ void tick();
77
78 void close();
79 void moveToBack();
80
81 // Returns the rect, relative to gNotifyView, where this
82 // notify box should be placed.
83 static LLRect getNotifyRect(S32 num_options, BOOL layout_script_dialog);
84 static LLRect getNotifyTipRect(const LLString &message);
85
86 // internal handler for button being clicked
87 static void onClickButton(void* data);
88
89 // for "next" button
90 static void onClickNext(void* data);
91
92private:
93 void drawBackground() const;
94
95protected:
96 BOOL mIsTip;
97 BOOL mAnimating; // Are we sliding onscreen?
98
99 // Time since this notification was displayed.
100 // This is an LLTimer not a frame timer because I am concerned
101 // that I could be out-of-sync by one frame in the animation.
102 LLTimer mTimer;
103
104 LLButton* mNextBtn;
105
106 notify_callback_t mCallback;
107 void* mData;
108 S32 mNumOptions;
109 S32 mDefaultOption;
110
111 // Used for callbacks
112 struct InstanceAndS32
113 {
114 LLNotifyBox* mSelf;
115 S32 mButton;
116 };
117 LLDynamicArray<InstanceAndS32*> mBtnCallbackData;
118
119 typedef std::map<LLString, LLPointer<LLNotifyBoxTemplate> > template_map_t;
120 static template_map_t sNotifyTemplates; // by mLabel
121
122 static S32 sNotifyBoxCount;
123 static const LLFontGL* sFont;
124 static const LLFontGL* sFontSmall;
125};
126
127class LLNotifyBoxView : public LLUICtrl
128{
129public:
130 LLNotifyBoxView(const LLString& name, const LLRect& rect, BOOL mouse_opaque, U32 follows=FOLLOWS_NONE);
131 void showOnly(LLView * ctrl);
132 LLNotifyBox * getFirstNontipBox() const;
133
134 virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_VIEW; };
135 virtual LLString getWidgetTag() const { return ""; }
136};
137
138// This view contains the stack of notification windows.
139extern LLNotifyBoxView* gNotifyBoxView;
140
141class LLNotifyBoxTemplate : public LLRefCount
142{
143public:
144 LLNotifyBoxTemplate() : mIsTip(FALSE), mDefaultOption(0) {}
145
146 void setMessage(const LLString& message)
147 {
148 mMessage = message;
149 }
150
151 void addOption(const LLString& label, BOOL is_default = FALSE)
152 {
153 if (is_default)
154 {
155 mDefaultOption = mOptions.size();
156 }
157 mOptions.push_back(label);
158 }
159
160public:
161 LLString mLabel; // Handle for access from code, etc
162 LLString mMessage; // Message to display
163 BOOL mIsTip;
164 LLNotifyBox::option_list_t mOptions;
165 S32 mDefaultOption;
166};
167
168#endif