aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/lluploaddialog.cpp
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/lluploaddialog.cpp
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 '')
-rw-r--r--linden/indra/newview/lluploaddialog.cpp168
1 files changed, 168 insertions, 0 deletions
diff --git a/linden/indra/newview/lluploaddialog.cpp b/linden/indra/newview/lluploaddialog.cpp
new file mode 100644
index 0000000..a67aa7d
--- /dev/null
+++ b/linden/indra/newview/lluploaddialog.cpp
@@ -0,0 +1,168 @@
1/**
2 * @file lluploaddialog.cpp
3 * @brief LLUploadDialog class implementation
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#include "llviewerprecompiledheaders.h"
29
30#include "lluploaddialog.h"
31#include "llviewerwindow.h"
32#include "llfontgl.h"
33#include "llresmgr.h"
34#include "lltextbox.h"
35#include "llbutton.h"
36#include "llkeyboard.h"
37#include "llfocusmgr.h"
38#include "llviewercontrol.h"
39
40// static
41LLUploadDialog* LLUploadDialog::sDialog = NULL;
42
43// static
44LLUploadDialog* LLUploadDialog::modalUploadDialog(const std::string& msg)
45{
46 // Note: object adds, removes, and destroys itself.
47 return new LLUploadDialog(msg);
48}
49
50// static
51void LLUploadDialog::modalUploadFinished()
52{
53 // Note: object adds, removes, and destroys itself.
54 delete LLUploadDialog::sDialog;
55 LLUploadDialog::sDialog = NULL;
56}
57
58////////////////////////////////////////////////////////////
59// Private methods
60
61LLUploadDialog::LLUploadDialog( const std::string& msg)
62 :
63 LLPanel( "Uploading...", LLRect(0,100,100,0) ) // dummy rect. Will reshape below.
64{
65 setBackgroundVisible( TRUE );
66
67 if( LLUploadDialog::sDialog )
68 {
69 delete LLUploadDialog::sDialog;
70 }
71 LLUploadDialog::sDialog = this;
72
73 const LLFontGL* font = gResMgr->getRes( LLFONT_SANSSERIF );
74 LLRect msg_rect;
75 for (int line_num=0; line_num<16; ++line_num)
76 {
77 mLabelBox[line_num] = new LLTextBox( "Filename", msg_rect, "", font );
78 addChild(mLabelBox[line_num]);
79 }
80
81 setMessage(msg);
82
83 // The dialog view is a root view
84 gViewerWindow->setTopView( this, NULL );
85}
86
87void LLUploadDialog::setMessage( const std::string& msg)
88{
89 const LLFontGL* font = gResMgr->getRes( LLFONT_SANSSERIF );
90
91 const S32 VPAD = 16;
92 const S32 HPAD = 25;
93
94 // Make the text boxes a little wider than the text
95 const S32 TEXT_PAD = 8;
96
97 // Split message into lines, separated by '\n'
98 S32 max_msg_width = 0;
99 LLDoubleLinkedList<LLString> msg_lines;
100
101 S32 size = msg.size() + 1;// + strlen("Uploading...\n\n");
102 char* temp_msg = new char[size];
103
104 //strcpy(temp_msg,"Uploading...\n\n");
105 strcpy( temp_msg, msg.c_str());
106
107 char* token = strtok( temp_msg, "\n" );
108 while( token )
109 {
110 S32 cur_width = S32(font->getWidth(token) + 0.99f) + TEXT_PAD;
111 max_msg_width = llmax( max_msg_width, cur_width );
112 msg_lines.addDataAtEnd( new LLString( token ) );
113 token = strtok( NULL, "\n" );
114 }
115 delete[] temp_msg;
116
117
118 S32 line_height = S32( font->getLineHeight() + 0.99f );
119 S32 dialog_width = max_msg_width + 2 * HPAD;
120 S32 dialog_height = line_height * msg_lines.getLength() + 2 * VPAD;
121
122 reshape( dialog_width, dialog_height, FALSE );
123
124 // Message
125 S32 msg_x = (mRect.getWidth() - max_msg_width) / 2;
126 S32 msg_y = mRect.getHeight() - VPAD - line_height;
127 int line_num;
128 for (line_num=0; line_num<16; ++line_num)
129 {
130 mLabelBox[line_num]->setVisible(FALSE);
131 }
132 line_num = 0;
133 for( LLString* cur_line = msg_lines.getFirstData(); cur_line; cur_line = msg_lines.getNextData() )
134 {
135 LLRect msg_rect;
136 msg_rect.setOriginAndSize( msg_x, msg_y, max_msg_width, line_height );
137 mLabelBox[line_num]->setRect(msg_rect);
138 mLabelBox[line_num]->setText(*cur_line);
139 mLabelBox[line_num]->setColor( gColors.getColor( "LabelTextColor" ) );
140 mLabelBox[line_num]->setVisible(TRUE);
141 msg_y -= line_height;
142 ++line_num;
143 }
144 msg_lines.deleteAllData();
145
146 centerDialog();
147}
148
149LLUploadDialog::~LLUploadDialog()
150{
151 gFocusMgr.releaseFocusIfNeeded( this );
152
153// LLFilePicker::instance().reset();
154
155
156 LLUploadDialog::sDialog = NULL;
157}
158
159void LLUploadDialog::centerDialog()
160{
161 LLRect window_rect = gViewerWindow->getRootView()->getRect();
162
163 S32 dialog_left = window_rect.mLeft + (window_rect.getWidth() - mRect.getWidth()) / 2;
164 S32 dialog_bottom = window_rect.mBottom + (window_rect.getHeight() - mRect.getHeight()) / 2;
165
166 translate( dialog_left - mRect.mLeft, dialog_bottom - mRect.mBottom );
167}
168