aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llui/llalertdialog.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/llui/llalertdialog.h180
1 files changed, 180 insertions, 0 deletions
diff --git a/linden/indra/llui/llalertdialog.h b/linden/indra/llui/llalertdialog.h
new file mode 100644
index 0000000..1085f23
--- /dev/null
+++ b/linden/indra/llui/llalertdialog.h
@@ -0,0 +1,180 @@
1/**
2 * @file llalertdialog.h
3 * @brief LLAlertDialog base class
4 *
5 * Copyright (c) 2001-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_ALERTDIALOG_H
29#define LL_ALERTDIALOG_H
30
31#include "llpanel.h"
32#include "llmodaldialog.h"
33#include "llmemory.h"
34#include "llui.h"
35
36class LLButton;
37class LLCheckBoxCtrl;
38class LLAlertDialogTemplate;
39class LLLineEditor;
40
41class LLAlertDialog : public LLModalDialog
42{
43public:
44 typedef void (*alert_callback_t)(S32 option, void* user_data);
45 typedef void (*alert_text_callback_t)(S32 option, const LLString& text, void* user_data);
46 typedef bool (*display_callback_t)(S32 modal);
47 enum { IGNORE_USE_DEFAULT=1, IGNORE_USE_SAVED=2, IGNORE_SHOW_AGAIN=3 };
48
49protected:
50 struct ButtonData
51 {
52 LLAlertDialog* mSelf;
53 LLButton* mButton;
54 S32 mOption;
55 };
56
57public:
58 virtual BOOL handleKeyHere(KEY key, MASK mask, BOOL called_from_parent );
59
60 virtual void draw();
61 virtual void setVisible( BOOL visible );
62
63 bool setCheckBox( const LLString&, const LLString& );
64 void setOptionEnabled( S32 option, BOOL enable );
65 // If mUnique==TRUE only one copy of this message should exist
66 void setUnique(BOOL val = TRUE) { mUnique = val; }
67 void setEditTextCallback(alert_text_callback_t callback, void *user_data);
68 void setEditTextArgs(const LLString::format_map_t& edit_args);
69 void setDrawAsterixes(BOOL enable);
70
71 bool show(); // May instantly destroy the message if it is unique (returns false)
72
73 //statics
74 static void onButtonPressed(void* userdata);
75
76 static LLAlertDialog* createXml( const LLString& xml_desc,
77 alert_callback_t callback = NULL, void *user_data = NULL);
78 static LLAlertDialog* createXml( const LLString& xml_desc, const LLString::format_map_t& args,
79 alert_callback_t callback = NULL, void *user_data = NULL);
80
81 static LLAlertDialog* showXml( const LLString& xml_desc,
82 alert_callback_t callback = NULL, void *user_data = NULL);
83 static LLAlertDialog* showXml( const LLString& xml_desc, const LLString::format_map_t& args,
84 alert_callback_t callback = NULL, void *user_data = NULL);
85
86 static LLAlertDialog* showCritical( const LLString& msg, alert_callback_t callback = NULL, void *user_data = NULL);
87
88 static bool parseAlerts(const LLString& xml_filename, LLControlGroup* settings = NULL, BOOL settings_only = FALSE);
89 static const LLString& getTemplateMessage(const LLString& xml_desc);
90
91 static void setDisplayCallback(display_callback_t callback) { sDisplayCallback = callback; }
92
93 // Must call show() after creating these
94 LLAlertDialog( const LLAlertDialogTemplate* xml_template, const LLString::format_map_t& args,
95 alert_callback_t callback = NULL, void *user_data = NULL);
96
97 static void format(LLString& msg, const LLString::format_map_t& args);
98
99protected:
100 void createDialog(const std::vector<LLString>* options, S32 default_option,
101 const LLString& msg, const LLString::format_map_t& args,
102 const LLString& edit_text);
103
104 virtual ~LLAlertDialog(); // No you can't kill it. It can only kill itself.
105
106 // Does it have a readable title label, or minimize or close buttons?
107 BOOL hasTitleBar() const;
108
109protected:
110 alert_callback_t mCallback;
111 void* mUserData;
112 S32 mNumOptions;
113 S32 mDefaultOption;
114 BOOL mOptionChosen;
115 LLCheckBoxCtrl* mCheck;
116 BOOL mUnique;
117 S32 mIgnorable;
118 LLString mLabel;
119 LLString mIgnoreLabel;
120 ButtonData* mButtonData;
121 LLFrameTimer mDefaultBtnTimer;
122 // For Dialogs that take a line as text as input:
123 LLLineEditor* mLineEditor;
124 alert_text_callback_t mTextCallback;
125
126public:
127 // use LLPointer so they delete themselves when sTemplates is destroyed
128 typedef std::map<LLString, LLPointer<LLAlertDialogTemplate> > template_map_t;
129 static template_map_t sAlertTemplates; // by mLabel
130 static template_map_t sIgnorableTemplates; // by mIgnoreLabel
131 static LLControlGroup* sSettings;
132 static std::map<LLString, LLAlertDialog*> sUniqueActiveMap;
133 static display_callback_t sDisplayCallback;
134};
135
136//============================================================================
137
138class LLAlertDialogTemplate : public LLRefCount
139{
140public:
141 LLAlertDialogTemplate() : mTitle(""), mModal(FALSE), mUnique(FALSE), mIgnorable(0), mDefaultOption(0) {}
142
143 void addOption(const LLString& label, const LLString& ignore_text, BOOL is_default = FALSE)
144 {
145 if (is_default)
146 {
147 mDefaultOption = mOptions.size();
148 }
149 mOptions.push_back(label);
150 mOptionDefaultText.push_back(ignore_text);
151 }
152
153 S32 getIgnore()
154 {
155 if (mIgnorable)
156 {
157 return LLAlertDialog::sSettings->getWarning(mIgnoreLabel) ? FALSE : mIgnorable;
158 }
159 else
160 {
161 return FALSE;
162 }
163 }
164
165public:
166 LLString mLabel; // Handle for access from code, etc
167 LLString mTitle; // (optional) text to display in title bar
168 LLString mMessage; // Message to display
169 LLString mIgnoreListText; // Text to display in enable/disable dialog (if mIgnorable == TRUE)
170 LLString mIgnoreLabel; // Handle for ignore variable (may be shared by multiple templates)
171 BOOL mModal;
172 BOOL mUnique;
173 S32 mIgnorable; // 0 = Never Ignore, 1 = Do default option, 2 = Do saved option
174 std::vector<LLString> mOptions;
175 std::vector<LLString> mOptionDefaultText;
176 S32 mDefaultOption;
177 LLString mEditLineText;
178};
179
180#endif // LL_ALERTDIALOG_H