aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llfloaterhtmlfind.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/llfloaterhtmlfind.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 'linden/indra/newview/llfloaterhtmlfind.cpp')
-rw-r--r--linden/indra/newview/llfloaterhtmlfind.cpp205
1 files changed, 205 insertions, 0 deletions
diff --git a/linden/indra/newview/llfloaterhtmlfind.cpp b/linden/indra/newview/llfloaterhtmlfind.cpp
new file mode 100644
index 0000000..b233c1b
--- /dev/null
+++ b/linden/indra/newview/llfloaterhtmlfind.cpp
@@ -0,0 +1,205 @@
1/**
2 * @file llfloaterhtmlfind.cpp
3 * @brief HTML Find floater - uses embedded web browser control
4 *
5 * Copyright (c) 2006-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
31#include "llfloaterhtmlfind.h"
32
33#include "llvieweruictrlfactory.h"
34#include "llbutton.h"
35#include "llwebbrowserctrl.h"
36#include "llviewerwindow.h"
37#include "llviewercontrol.h"
38#include "viewer.h"
39#include "llfloaterworldmap.h"
40#include "llfloater.h"
41
42#if LL_LIBXUL_ENABLED
43
44class LLFloaterHtmlFind :
45 public LLFloater,
46 public LLWebBrowserCtrlObserver
47{
48public:
49 LLFloaterHtmlFind();
50 virtual ~LLFloaterHtmlFind();
51
52 virtual BOOL postBuild();
53 virtual void onClose( bool app_quitting );
54 virtual void draw();
55
56 static void show( void* url_string = NULL );
57 static void onClickClose( void* data );
58
59 static void onFocusGained( LLUICtrl* ctrl, void* data );
60
61 // embedded browser observables
62 virtual void onClickLinkHref( const EventType& eventIn );
63
64protected:
65 LLWebBrowserCtrl* mWebBrowser;
66 static LLFloaterHtmlFind* sInstance;
67 LLButton* mCloseButton;
68};
69
70LLFloaterHtmlFind* LLFloaterHtmlFind::sInstance = 0;
71
72////////////////////////////////////////////////////////////////////////////////
73//
74LLFloaterHtmlFind::LLFloaterHtmlFind() :
75 LLFloater( "HTML Find" ),
76 mWebBrowser( 0 ),
77 mCloseButton( 0 )
78{
79 sInstance = this;
80}
81
82////////////////////////////////////////////////////////////////////////////////
83//
84LLFloaterHtmlFind::~LLFloaterHtmlFind()
85{
86 // stop observing browser events
87 if ( mWebBrowser )
88 {
89 mWebBrowser->remObserver( this );
90 };
91
92 // save position of floater
93 gSavedSettings.setRect( "HtmlFindRect", mRect );
94
95 sInstance = 0;
96}
97
98////////////////////////////////////////////////////////////////////////////////
99//
100BOOL LLFloaterHtmlFind::postBuild()
101{
102 mCloseButton = LLUICtrlFactory::getButtonByName(this, "close_btn" );
103 if ( mCloseButton )
104 {
105 mCloseButton->setClickedCallback( onClickClose );
106 mCloseButton->setCallbackUserData( this );
107 setDefaultBtn( mCloseButton );
108 };
109
110 mWebBrowser = LLViewerUICtrlFactory::getWebBrowserByName(this, "html_find_browser" );
111
112 // // observe browser events
113 mWebBrowser->addObserver( this );
114
115 // browser built so navigate to the right page
116 LLString homePageUrl( "http://user.lindenlab.com/~callum/search.php" );
117 mWebBrowser->navigateTo( homePageUrl );
118
119 return TRUE;
120}
121
122////////////////////////////////////////////////////////////////////////////////
123//
124void LLFloaterHtmlFind::draw()
125{
126 // just call the base class for now - more later
127 LLFloater::draw();
128}
129
130////////////////////////////////////////////////////////////////////////////////
131//
132void LLFloaterHtmlFind::show( void* url_string )
133{
134 if ( sInstance )
135 {
136 sInstance->setVisibleAndFrontmost();
137 return;
138 };
139
140 LLFloaterHtmlFind* self = new LLFloaterHtmlFind;
141
142 // create floater from its XML definition
143 gUICtrlFactory->buildFloater( self, "floater_html_find.xml" );
144
145 // reposition floater from saved settings
146 LLRect rect = gSavedSettings.getRect( "HtmlFindRect" );
147 self->reshape( rect.getWidth(), rect.getHeight(), FALSE );
148 self->setRect( rect );
149}
150
151////////////////////////////////////////////////////////////////////////////////
152//
153void LLFloaterHtmlFind::onClose( bool app_quitting )
154{
155 setVisible( false );
156}
157
158////////////////////////////////////////////////////////////////////////////////
159//
160void LLFloaterHtmlFind::onClickClose( void* data )
161{
162 LLFloaterHtmlFind* self = ( LLFloaterHtmlFind* )data;
163
164 self->setVisible( false );
165}
166
167////////////////////////////////////////////////////////////////////////////////
168// virtual (observer on enbedded browser)
169void LLFloaterHtmlFind::onClickLinkHref( const EventType& eventIn )
170{
171 #if !LL_RELEASE_FOR_DOWNLOAD
172 llinfos << "MOZ> onClickHref=" << eventIn.getStringValue() << llendl;
173 #endif
174 // if it was a secondlife:// address
175 if ( eventIn.getStringValue().substr( 0, std::string( "secondlife://" ).length() ) == "secondlife://" )
176 {
177 // parse out sim name and coordinates
178 LLURLSimString::setString( eventIn.getStringValue() );
179 LLURLSimString::parse();
180
181 // if there is a world map
182 if ( gFloaterWorldMap )
183 {
184 #if !LL_RELEASE_FOR_DOWNLOAD
185 llinfos << "MOZ> sim name is [" << LLURLSimString::sInstance.mSimName.c_str() << "]" << llendl;
186 #endif
187 // mark where the destination is
188 gFloaterWorldMap->trackURL( LLURLSimString::sInstance.mSimName.c_str(),
189 LLURLSimString::sInstance.mX,
190 LLURLSimString::sInstance.mY,
191 LLURLSimString::sInstance.mZ );
192
193 // display map
194 LLFloaterWorldMap::show( NULL, TRUE );
195 };
196 };
197}
198
199// static
200void LLHtmlFind::show(void* url_string)
201{
202 LLFloaterHtmlFind::show(url_string);
203}
204
205#endif // LL_LIBXUL_ENABLED