aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llui/llalertdialog.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-09-06 18:24:57 -0500
committerJacek Antonelli2008-09-06 18:25:07 -0500
commit798d367d54a6c6379ad355bd8345fa40e31e7fe9 (patch)
tree1921f1708cd0240648c97bc02df2c2ab5f2fc41e /linden/indra/llui/llalertdialog.cpp
parentSecond Life viewer sources 1.20.15 (diff)
downloadmeta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.zip
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.gz
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.bz2
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.xz
Second Life viewer sources 1.21.0-RC
Diffstat (limited to 'linden/indra/llui/llalertdialog.cpp')
-rw-r--r--linden/indra/llui/llalertdialog.cpp104
1 files changed, 53 insertions, 51 deletions
diff --git a/linden/indra/llui/llalertdialog.cpp b/linden/indra/llui/llalertdialog.cpp
index 4ca9dc8..4be07e9 100644
--- a/linden/indra/llui/llalertdialog.cpp
+++ b/linden/indra/llui/llalertdialog.cpp
@@ -55,23 +55,23 @@ const S32 MSG_PAD = 8;
55/*static*/ LLAlertDialog::template_map_t LLAlertDialog::sAlertTemplates; 55/*static*/ LLAlertDialog::template_map_t LLAlertDialog::sAlertTemplates;
56/*static*/ LLAlertDialog::template_map_t LLAlertDialog::sIgnorableTemplates; 56/*static*/ LLAlertDialog::template_map_t LLAlertDialog::sIgnorableTemplates;
57/*static*/ LLControlGroup* LLAlertDialog::sSettings = NULL; 57/*static*/ LLControlGroup* LLAlertDialog::sSettings = NULL;
58/*static*/ std::map<LLString,LLAlertDialog*> LLAlertDialog::sUniqueActiveMap; 58/*static*/ std::map<std::string,LLAlertDialog*> LLAlertDialog::sUniqueActiveMap;
59/*static*/ LLAlertDialog::display_callback_t LLAlertDialog::sDisplayCallback; 59/*static*/ LLAlertDialog::display_callback_t LLAlertDialog::sDisplayCallback;
60/*static*/ LLString LLAlertDialog::sStringSkipNextTime("Skip this dialog next time"); 60/*static*/ std::string LLAlertDialog::sStringSkipNextTime("Skip this dialog next time");
61/*static*/ LLString LLAlertDialog::sStringAlwaysChoose("Always choose this option"); 61/*static*/ std::string LLAlertDialog::sStringAlwaysChoose("Always choose this option");
62/*static*/ LLAlertDialog::URLLoader* LLAlertDialog::sURLLoader; 62/*static*/ LLAlertDialog::URLLoader* LLAlertDialog::sURLLoader;
63 63
64 64
65//static 65//static
66LLAlertDialog* LLAlertDialog::createXml( const LLString& xml_desc, 66LLAlertDialog* LLAlertDialog::createXml( const std::string& xml_desc,
67 alert_callback_t callback, void *user_data) 67 alert_callback_t callback, void *user_data)
68{ 68{
69 LLString::format_map_t args; 69 LLStringUtil::format_map_t args;
70 return createXml(xml_desc, args, callback, user_data); 70 return createXml(xml_desc, args, callback, user_data);
71} 71}
72 72
73//static 73//static
74LLAlertDialog* LLAlertDialog::createXml( const LLString& xml_desc, const LLString::format_map_t& args, 74LLAlertDialog* LLAlertDialog::createXml( const std::string& xml_desc, const LLStringUtil::format_map_t& args,
75 alert_callback_t callback, void *user_data) 75 alert_callback_t callback, void *user_data)
76{ 76{
77 template_map_t::iterator iter = sAlertTemplates.find(xml_desc); 77 template_map_t::iterator iter = sAlertTemplates.find(xml_desc);
@@ -85,7 +85,7 @@ LLAlertDialog* LLAlertDialog::createXml( const LLString& xml_desc, const LLStrin
85 } 85 }
86 else 86 else
87 { 87 {
88 LLString::format_map_t args; 88 LLStringUtil::format_map_t args;
89 args["[ALERT_NAME]"] = xml_desc; 89 args["[ALERT_NAME]"] = xml_desc;
90 llwarns << "Missing Alert: [" << xml_desc << "]" << llendl; 90 llwarns << "Missing Alert: [" << xml_desc << "]" << llendl;
91 LLAlertDialog* dialogp = LLAlertDialog::showXml("MissingAlert", args); 91 LLAlertDialog* dialogp = LLAlertDialog::showXml("MissingAlert", args);
@@ -98,15 +98,15 @@ LLAlertDialog* LLAlertDialog::createXml( const LLString& xml_desc, const LLStrin
98} 98}
99 99
100//static 100//static
101LLAlertDialog* LLAlertDialog::showXml( const LLString& xml_desc, 101LLAlertDialog* LLAlertDialog::showXml( const std::string& xml_desc,
102 alert_callback_t callback, void *user_data) 102 alert_callback_t callback, void *user_data)
103{ 103{
104 LLString::format_map_t args; 104 LLStringUtil::format_map_t args;
105 return showXml(xml_desc, args, callback, user_data); 105 return showXml(xml_desc, args, callback, user_data);
106} 106}
107 107
108//static 108//static
109LLAlertDialog* LLAlertDialog::showXml( const LLString& xml_desc, const LLString::format_map_t& args, 109LLAlertDialog* LLAlertDialog::showXml( const std::string& xml_desc, const LLStringUtil::format_map_t& args,
110 alert_callback_t callback, void *user_data) 110 alert_callback_t callback, void *user_data)
111{ 111{
112 LLAlertDialog* dialog = createXml(xml_desc, args, callback, user_data); 112 LLAlertDialog* dialog = createXml(xml_desc, args, callback, user_data);
@@ -114,10 +114,10 @@ LLAlertDialog* LLAlertDialog::showXml( const LLString& xml_desc, const LLString:
114} 114}
115 115
116//static 116//static
117LLAlertDialog* LLAlertDialog::showCritical( const LLString& desc, alert_callback_t callback, void *user_data) 117LLAlertDialog* LLAlertDialog::showCritical( const std::string& desc, alert_callback_t callback, void *user_data)
118{ 118{
119 LLAlertDialogTemplate xml_template; 119 LLAlertDialogTemplate xml_template;
120 LLString::format_map_t args; 120 LLStringUtil::format_map_t args;
121 xml_template.mTitle = "Critical Error"; 121 xml_template.mTitle = "Critical Error";
122 xml_template.mMessage = desc; 122 xml_template.mMessage = desc;
123 xml_template.mModal = TRUE; 123 xml_template.mModal = TRUE;
@@ -135,7 +135,7 @@ static const S32 BTN_HPAD = 8;
135static const LLFONT_ID font_name = LLFONT_SANSSERIF; 135static const LLFONT_ID font_name = LLFONT_SANSSERIF;
136 136
137LLAlertDialog::LLAlertDialog( const LLAlertDialogTemplate* xml_template, 137LLAlertDialog::LLAlertDialog( const LLAlertDialogTemplate* xml_template,
138 const LLString::format_map_t& args, 138 const LLStringUtil::format_map_t& args,
139 alert_callback_t callback, void *user_data) 139 alert_callback_t callback, void *user_data)
140 : LLModalDialog( xml_template->mTitle, 100, 100, xml_template->mModal ), // dummy size. Will reshape below. 140 : LLModalDialog( xml_template->mTitle, 100, 100, xml_template->mModal ), // dummy size. Will reshape below.
141 mCallback( callback ), 141 mCallback( callback ),
@@ -156,7 +156,7 @@ LLAlertDialog::LLAlertDialog( const LLAlertDialogTemplate* xml_template,
156{ 156{
157 mURL = xml_template->mURL; 157 mURL = xml_template->mURL;
158 mURLOption = xml_template->mURLOption; 158 mURLOption = xml_template->mURLOption;
159 createDialog(&(xml_template->mOptions), xml_template->mDefaultOption, 159 createDialog(xml_template->mOptions, xml_template->mDefaultOption,
160 xml_template->mMessage, args, 160 xml_template->mMessage, args,
161 xml_template->mEditLineText); 161 xml_template->mEditLineText);
162 setTitle(xml_template->mTitle); 162 setTitle(xml_template->mTitle);
@@ -226,7 +226,7 @@ bool LLAlertDialog::show()
226 // Check to see if we are already displaying the alert 226 // Check to see if we are already displaying the alert
227 if (mUnique) 227 if (mUnique)
228 { 228 {
229 std::map<LLString,LLAlertDialog*>::iterator iter = sUniqueActiveMap.find(mLabel); 229 std::map<std::string,LLAlertDialog*>::iterator iter = sUniqueActiveMap.find(mLabel);
230 if (iter != sUniqueActiveMap.end()) 230 if (iter != sUniqueActiveMap.end())
231 { 231 {
232 gFloaterView->bringToFront(iter->second); 232 gFloaterView->bringToFront(iter->second);
@@ -254,18 +254,18 @@ bool LLAlertDialog::show()
254 return true; 254 return true;
255} 255}
256 256
257void LLAlertDialog::format(LLString& msg, const LLString::format_map_t& args) 257void LLAlertDialog::format(std::string& msg, const LLStringUtil::format_map_t& args)
258{ 258{
259 // XUI:translate! 259 // XUI:translate!
260 LLString::format_map_t targs = args; 260 LLStringUtil::format_map_t targs = args;
261 targs["[SECOND_LIFE]"] = "Second Life"; 261 targs["[SECOND_LIFE]"] = "Second Life";
262 targs["[_URL]"] = mURL; 262 targs["[_URL]"] = mURL;
263 LLString::format(msg, targs); 263 LLStringUtil::format(msg, targs);
264} 264}
265 265
266void LLAlertDialog::createDialog(const std::vector<LLString>* optionsp, S32 default_option, 266void LLAlertDialog::createDialog(const options_list_t& options_in, S32 default_option,
267 const LLString& msg_in, const LLString::format_map_t& args, 267 const std::string& msg_in, const LLStringUtil::format_map_t& args,
268 const LLString& edit_text) 268 const std::string& edit_text)
269{ 269{
270 setBackgroundVisible(TRUE); 270 setBackgroundVisible(TRUE);
271 setBackgroundOpaque(TRUE); 271 setBackgroundOpaque(TRUE);
@@ -274,9 +274,11 @@ void LLAlertDialog::createDialog(const std::vector<LLString>* optionsp, S32 defa
274 const S32 LINE_HEIGHT = llfloor(font->getLineHeight() + 0.99f); 274 const S32 LINE_HEIGHT = llfloor(font->getLineHeight() + 0.99f);
275 const S32 EDITOR_HEIGHT = 20; 275 const S32 EDITOR_HEIGHT = 20;
276 276
277 const options_list_t* optionsp = &options_in;
278
277 // Buttons 279 // Buttons
278 std::vector<LLString> default_option_list; 280 options_list_t default_option_list;
279 mNumOptions = optionsp->size(); 281 mNumOptions = options_in.size();
280 if( 0 == mNumOptions ) 282 if( 0 == mNumOptions )
281 { 283 {
282 default_option_list.push_back("Close"); 284 default_option_list.push_back("Close");
@@ -285,12 +287,13 @@ void LLAlertDialog::createDialog(const std::vector<LLString>* optionsp, S32 defa
285 mNumOptions = 1; 287 mNumOptions = 1;
286 } 288 }
287 289
288 const std::vector<LLString>& options = *optionsp; 290 const options_list_t& options= *optionsp;
291
289 mButtonData = new ButtonData[mNumOptions]; 292 mButtonData = new ButtonData[mNumOptions];
290 293
291 // Calc total width of buttons 294 // Calc total width of buttons
292 S32 button_width = 0; 295 S32 button_width = 0;
293 S32 sp = font->getWidth("OO"); 296 S32 sp = font->getWidth(std::string("OO"));
294 for( S32 i = 0; i < mNumOptions; i++ ) 297 for( S32 i = 0; i < mNumOptions; i++ )
295 { 298 {
296 S32 w = S32(font->getWidth( options[i] ) + 0.99f) + sp + 2 * LLBUTTON_H_PAD; 299 S32 w = S32(font->getWidth( options[i] ) + 0.99f) + sp + 2 * LLBUTTON_H_PAD;
@@ -304,10 +307,10 @@ void LLAlertDialog::createDialog(const std::vector<LLString>* optionsp, S32 defa
304 307
305 // Message: create text box using raw string, as text has been structure deliberately 308 // Message: create text box using raw string, as text has been structure deliberately
306 // Use size of created text box to generate dialog box size 309 // Use size of created text box to generate dialog box size
307 LLString msg = msg_in; 310 std::string msg = msg_in;
308 format( msg, args ); 311 format( msg, args );
309 llwarns << "Alert: " << msg << llendl; 312 llwarns << "Alert: " << msg << llendl;
310 LLTextBox* msg_box = new LLTextBox( "Alert message", msg, (F32)MAX_ALLOWED_MSG_WIDTH, font ); 313 LLTextBox* msg_box = new LLTextBox( std::string("Alert message"), msg, (F32)MAX_ALLOWED_MSG_WIDTH, font );
311 314
312 const LLRect& text_rect = msg_box->getRect(); 315 const LLRect& text_rect = msg_box->getRect();
313 S32 dialog_width = llmax( btn_total_width, text_rect.getWidth() ) + 2 * HPAD; 316 S32 dialog_width = llmax( btn_total_width, text_rect.getWidth() ) + 2 * HPAD;
@@ -339,7 +342,7 @@ void LLAlertDialog::createDialog(const std::vector<LLString>* optionsp, S32 defa
339 342
340 if (mCaution) 343 if (mCaution)
341 { 344 {
342 LLIconCtrl* icon = new LLIconCtrl("icon", LLRect(msg_x, msg_y, msg_x+32, msg_y-32), "notify_caution_icon.tga"); 345 LLIconCtrl* icon = new LLIconCtrl(std::string("icon"), LLRect(msg_x, msg_y, msg_x+32, msg_y-32), std::string("notify_caution_icon.tga"));
343 icon->setMouseOpaque(FALSE); 346 icon->setMouseOpaque(FALSE);
344 addChild(icon); 347 addChild(icon);
345 msg_x += 32 + HPAD; 348 msg_x += 32 + HPAD;
@@ -362,13 +365,12 @@ void LLAlertDialog::createDialog(const std::vector<LLString>* optionsp, S32 defa
362 LLRect button_rect; 365 LLRect button_rect;
363 button_rect.setOriginAndSize( button_left, VPAD, button_width, BTN_HEIGHT ); 366 button_rect.setOriginAndSize( button_left, VPAD, button_width, BTN_HEIGHT );
364 367
365 LLButton* btn = new LLButton( 368 LLButton* btn = new LLButton(std::string("btn"), button_rect,
366 "btn", button_rect, 369 LLStringUtil::null, LLStringUtil::null, LLStringUtil::null,
367 "","", "", 370 &LLAlertDialog::onButtonPressed, (void*)(&mButtonData[i]),
368 &LLAlertDialog::onButtonPressed, (void*)(&mButtonData[i]), 371 font,
369 font, 372 options[i],
370 options[i], 373 options[i]);
371 options[i]);
372 374
373 mButtonData[i].mSelf = this; 375 mButtonData[i].mSelf = this;
374 mButtonData[i].mButton = btn; 376 mButtonData[i].mButton = btn;
@@ -388,7 +390,7 @@ void LLAlertDialog::createDialog(const std::vector<LLString>* optionsp, S32 defa
388 if (edit_text.size() > 0) 390 if (edit_text.size() > 0)
389 { 391 {
390 S32 y = VPAD + BTN_HEIGHT + VPAD/2; 392 S32 y = VPAD + BTN_HEIGHT + VPAD/2;
391 mLineEditor = new LLLineEditor("lineeditor", 393 mLineEditor = new LLLineEditor(std::string("lineeditor"),
392 LLRect( HPAD, y+EDITOR_HEIGHT, dialog_width-HPAD, y), 394 LLRect( HPAD, y+EDITOR_HEIGHT, dialog_width-HPAD, y),
393 edit_text, 395 edit_text,
394 LLFontGL::sSansSerif, 396 LLFontGL::sSansSerif,
@@ -397,7 +399,7 @@ void LLAlertDialog::createDialog(const std::vector<LLString>* optionsp, S32 defa
397 } 399 }
398} 400}
399 401
400bool LLAlertDialog::setCheckBox( const LLString& check_title, const LLString& check_control ) 402bool LLAlertDialog::setCheckBox( const std::string& check_title, const std::string& check_control )
401{ 403{
402 const LLFontGL* font = LLResMgr::getInstance()->getRes( font_name ); 404 const LLFontGL* font = LLResMgr::getInstance()->getRes( font_name );
403 const S32 LINE_HEIGHT = llfloor(font->getLineHeight() + 0.99f); 405 const S32 LINE_HEIGHT = llfloor(font->getLineHeight() + 0.99f);
@@ -420,7 +422,7 @@ bool LLAlertDialog::setCheckBox( const LLString& check_title, const LLString& ch
420 check_rect.setOriginAndSize(msg_x, VPAD+BTN_HEIGHT+LINE_HEIGHT/2, 422 check_rect.setOriginAndSize(msg_x, VPAD+BTN_HEIGHT+LINE_HEIGHT/2,
421 max_msg_width, LINE_HEIGHT); 423 max_msg_width, LINE_HEIGHT);
422 424
423 mCheck = new LLCheckboxCtrl("check", check_rect, check_title, font); 425 mCheck = new LLCheckboxCtrl(std::string("check"), check_rect, check_title, font);
424 addChild(mCheck); 426 addChild(mCheck);
425 427
426 // mCheck is sometimes "show again" and sometimes "hide" :-( 428 // mCheck is sometimes "show again" and sometimes "hide" :-(
@@ -508,7 +510,7 @@ void LLAlertDialog::handleCallbacks()
508} 510}
509BOOL LLAlertDialog::hasTitleBar() const 511BOOL LLAlertDialog::hasTitleBar() const
510{ 512{
511 return (getTitle() != "" && getTitle() != " ") // has title 513 return (getCurrentTitle() != "" && getCurrentTitle() != " ") // has title
512 || isMinimizeable() 514 || isMinimizeable()
513 || isCloseable(); 515 || isCloseable();
514} 516}
@@ -586,11 +588,11 @@ void LLAlertDialog::setEditTextCallback(alert_text_callback_t callback, void *us
586 } 588 }
587} 589}
588 590
589void LLAlertDialog::setEditTextArgs(const LLString::format_map_t& edit_args) 591void LLAlertDialog::setEditTextArgs(const LLStringUtil::format_map_t& edit_args)
590{ 592{
591 if (mLineEditor) 593 if (mLineEditor)
592 { 594 {
593 LLString msg = mLineEditor->getText(); 595 std::string msg = mLineEditor->getText();
594 format(msg, edit_args); 596 format(msg, edit_args);
595 mLineEditor->setText(msg); 597 mLineEditor->setText(msg);
596 } 598 }
@@ -625,7 +627,7 @@ void LLAlertDialog::onButtonPressed( void* userdata )
625//============================================================================= 627//=============================================================================
626 628
627//static 629//static
628const LLString& LLAlertDialog::getTemplateMessage(const LLString& xml_desc) 630const std::string& LLAlertDialog::getTemplateMessage(const std::string& xml_desc)
629{ 631{
630 template_map_t::iterator iter = sAlertTemplates.find(xml_desc); 632 template_map_t::iterator iter = sAlertTemplates.find(xml_desc);
631 if (iter != sAlertTemplates.end()) 633 if (iter != sAlertTemplates.end())
@@ -639,7 +641,7 @@ const LLString& LLAlertDialog::getTemplateMessage(const LLString& xml_desc)
639} 641}
640 642
641//static 643//static
642bool LLAlertDialog::parseAlerts(const LLString& xml_filename, LLControlGroup* settings, BOOL settings_only) 644bool LLAlertDialog::parseAlerts(const std::string& xml_filename, LLControlGroup* settings, BOOL settings_only)
643{ 645{
644 LLXMLNodePtr root; 646 LLXMLNodePtr root;
645 BOOL success = LLUICtrlFactory::getLayeredXMLNode(xml_filename, root); 647 BOOL success = LLUICtrlFactory::getLayeredXMLNode(xml_filename, root);
@@ -663,7 +665,7 @@ bool LLAlertDialog::parseAlerts(const LLString& xml_filename, LLControlGroup* se
663 { 665 {
664 if (alert->hasName("global")) 666 if (alert->hasName("global"))
665 { 667 {
666 LLString global_name; 668 std::string global_name;
667 if (alert->getAttributeString("name", global_name)) 669 if (alert->getAttributeString("name", global_name))
668 { 670 {
669 if (global_name == "skipnexttime") 671 if (global_name == "skipnexttime")
@@ -686,7 +688,7 @@ bool LLAlertDialog::parseAlerts(const LLString& xml_filename, LLControlGroup* se
686 LLAlertDialogTemplate* xml_template = settings_only ? NULL : new LLAlertDialogTemplate; 688 LLAlertDialogTemplate* xml_template = settings_only ? NULL : new LLAlertDialogTemplate;
687 689
688 // name= 690 // name=
689 LLString alert_name; 691 std::string alert_name;
690 if (alert->getAttributeString("name", alert_name)) 692 if (alert->getAttributeString("name", alert_name))
691 { 693 {
692 if (xml_template) 694 if (xml_template)
@@ -701,7 +703,7 @@ bool LLAlertDialog::parseAlerts(const LLString& xml_filename, LLControlGroup* se
701 continue; 703 continue;
702 } 704 }
703 // title= 705 // title=
704 LLString title; 706 std::string title;
705 if (alert->getAttributeString("title", title)) 707 if (alert->getAttributeString("title", title))
706 { 708 {
707 if (xml_template) 709 if (xml_template)
@@ -767,10 +769,10 @@ bool LLAlertDialog::parseAlerts(const LLString& xml_filename, LLControlGroup* se
767 // <option> 769 // <option>
768 if (child->hasName("option")) 770 if (child->hasName("option"))
769 { 771 {
770 LLString label = child->getTextContents(); 772 std::string label = child->getTextContents();
771 BOOL is_default = FALSE; 773 BOOL is_default = FALSE;
772 child->getAttributeBOOL("default", is_default); 774 child->getAttributeBOOL("default", is_default);
773 LLString ignore_text; 775 std::string ignore_text;
774 if (!child->getAttributeString("ignore", ignore_text)) 776 if (!child->getAttributeString("ignore", ignore_text))
775 { 777 {
776 ignore_text = label; 778 ignore_text = label;
@@ -802,9 +804,9 @@ bool LLAlertDialog::parseAlerts(const LLString& xml_filename, LLControlGroup* se
802 // <ignore> 804 // <ignore>
803 if (child->hasName("ignore")) 805 if (child->hasName("ignore"))
804 { 806 {
805 LLString ignore_text = child->getTextContents(); 807 std::string ignore_text = child->getTextContents();
806 // label= 808 // label=
807 LLString name; 809 std::string name;
808 child->getAttributeString("name", name); 810 child->getAttributeString("name", name);
809 811
810 //always set to alert_name for the sake of i18n 812 //always set to alert_name for the sake of i18n
@@ -839,7 +841,7 @@ bool LLAlertDialog::parseAlerts(const LLString& xml_filename, LLControlGroup* se
839 } 841 }
840 if (add_settings) 842 if (add_settings)
841 { 843 {
842 settings->declareS32("Default" + name, default_option, "Default option number for this alert dialog"); 844 settings->declareS32(std::string("Default") + name, default_option, std::string("Default option number for this alert dialog"));
843 } 845 }
844 } 846 }
845 } 847 }