diff options
author | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
commit | 38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch) | |
tree | adca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/llfloaterhtmlhelp.cpp | |
parent | README.txt (diff) | |
download | meta-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/llfloaterhtmlhelp.cpp | 264 |
1 files changed, 264 insertions, 0 deletions
diff --git a/linden/indra/newview/llfloaterhtmlhelp.cpp b/linden/indra/newview/llfloaterhtmlhelp.cpp new file mode 100644 index 0000000..50dd14c --- /dev/null +++ b/linden/indra/newview/llfloaterhtmlhelp.cpp | |||
@@ -0,0 +1,264 @@ | |||
1 | /** | ||
2 | * @file llfloaterhtmlhelp.cpp | ||
3 | * @brief HTML Help 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 | #include "llfloaterhtmlhelp.h" | ||
31 | |||
32 | #include "llvieweruictrlfactory.h" | ||
33 | #include "llwebbrowserctrl.h" | ||
34 | #include "llviewerwindow.h" | ||
35 | #include "llviewercontrol.h" | ||
36 | |||
37 | #if LL_LIBXUL_ENABLED | ||
38 | |||
39 | class LLFloaterHtmlHelp : | ||
40 | public LLFloater, | ||
41 | public LLWebBrowserCtrlObserver | ||
42 | { | ||
43 | public: | ||
44 | LLFloaterHtmlHelp(); | ||
45 | virtual ~LLFloaterHtmlHelp(); | ||
46 | |||
47 | virtual void onClose( bool app_quitting ); | ||
48 | virtual void draw(); | ||
49 | |||
50 | static void show( void* url_string = NULL ); | ||
51 | static void onClickBack( void* data ); | ||
52 | static void onClickHome( void* data ); | ||
53 | static void onClickForward( void* data ); | ||
54 | static void onClickClose( void* data ); | ||
55 | |||
56 | // browser observer impls | ||
57 | virtual void onStatusTextChange( const EventType& eventIn ); | ||
58 | virtual void onLocationChange( const EventType& eventIn ); | ||
59 | |||
60 | // used for some stats logging - will be removed at some point | ||
61 | static BOOL sFloaterOpened; | ||
62 | |||
63 | protected: | ||
64 | LLWebBrowserCtrl* mWebBrowser; | ||
65 | static LLFloaterHtmlHelp* sInstance; | ||
66 | LLButton* mBackButton; | ||
67 | LLButton* mForwardButton; | ||
68 | LLButton* mCloseButton; | ||
69 | LLTextBox* mStatusText; | ||
70 | LLString mStatusTextContents; | ||
71 | LLString mCurrentUrl; | ||
72 | }; | ||
73 | |||
74 | LLFloaterHtmlHelp* LLFloaterHtmlHelp::sInstance = 0; | ||
75 | |||
76 | BOOL LLFloaterHtmlHelp::sFloaterOpened = FALSE; | ||
77 | |||
78 | //////////////////////////////////////////////////////////////////////////////// | ||
79 | // | ||
80 | LLFloaterHtmlHelp::LLFloaterHtmlHelp() | ||
81 | : LLFloater( "HTML Help" ), | ||
82 | mWebBrowser( 0 ), | ||
83 | mStatusTextContents( "" ), | ||
84 | mCurrentUrl( "" ) | ||
85 | { | ||
86 | sInstance = this; | ||
87 | |||
88 | // create floater from its XML definition | ||
89 | gUICtrlFactory->buildFloater( this, "floater_html_help.xml" ); | ||
90 | |||
91 | childSetAction("back_btn", onClickBack, this); | ||
92 | childSetAction("home_btn", onClickHome, this); | ||
93 | childSetAction("forward_btn", onClickForward, this); | ||
94 | childSetAction("close_btn", onClickClose, this); | ||
95 | |||
96 | setDefaultBtn("close_btn"); | ||
97 | |||
98 | mWebBrowser = LLViewerUICtrlFactory::getWebBrowserByName(this, "html_help_browser" ); | ||
99 | if ( mWebBrowser ) | ||
100 | { | ||
101 | // observe browser control events | ||
102 | mWebBrowser->addObserver( this ); | ||
103 | |||
104 | // if the last page we were at before the client was closed is valid, go there and | ||
105 | // override what is in the XML file | ||
106 | // (not when the window was closed - it's only ever hidden - not closed) | ||
107 | |||
108 | LLString lastPageUrl = gSavedSettings.getString( "HtmlHelpLastPage" ); | ||
109 | if ( lastPageUrl != "" ) | ||
110 | { | ||
111 | mWebBrowser->navigateTo( lastPageUrl ); | ||
112 | }; | ||
113 | }; | ||
114 | } | ||
115 | |||
116 | //////////////////////////////////////////////////////////////////////////////// | ||
117 | // | ||
118 | LLFloaterHtmlHelp::~LLFloaterHtmlHelp() | ||
119 | { | ||
120 | // stop observing browser events | ||
121 | if ( mWebBrowser ) | ||
122 | { | ||
123 | mWebBrowser->remObserver( this ); | ||
124 | }; | ||
125 | |||
126 | // save position of floater | ||
127 | gSavedSettings.setRect( "HtmlHelpRect", mRect ); | ||
128 | |||
129 | // save the location we were at when SL closed | ||
130 | gSavedSettings.setString( "HtmlHelpLastPage", mCurrentUrl ); | ||
131 | |||
132 | sInstance = 0; | ||
133 | } | ||
134 | |||
135 | //////////////////////////////////////////////////////////////////////////////// | ||
136 | // virtual | ||
137 | void LLFloaterHtmlHelp::draw() | ||
138 | { | ||
139 | // enable/disable buttons depending on state | ||
140 | if ( mWebBrowser ) | ||
141 | { | ||
142 | bool enable_back = mWebBrowser->canNavigateBack(); | ||
143 | childSetEnabled( "back_btn", enable_back ); | ||
144 | |||
145 | bool enable_forward = mWebBrowser->canNavigateForward(); | ||
146 | childSetEnabled( "forward_btn", enable_forward ); | ||
147 | }; | ||
148 | |||
149 | LLFloater::draw(); | ||
150 | } | ||
151 | |||
152 | //////////////////////////////////////////////////////////////////////////////// | ||
153 | // | ||
154 | void LLFloaterHtmlHelp::show( void* url_string ) | ||
155 | { | ||
156 | sFloaterOpened = true; | ||
157 | |||
158 | if ( sInstance ) | ||
159 | { | ||
160 | sInstance->setVisibleAndFrontmost(); | ||
161 | return; | ||
162 | } | ||
163 | |||
164 | LLFloaterHtmlHelp* self = new LLFloaterHtmlHelp; | ||
165 | |||
166 | // reposition floater from saved settings | ||
167 | LLRect rect = gSavedSettings.getRect( "HtmlHelpRect" ); | ||
168 | self->reshape( rect.getWidth(), rect.getHeight(), FALSE ); | ||
169 | self->setRect( rect ); | ||
170 | } | ||
171 | |||
172 | //////////////////////////////////////////////////////////////////////////////// | ||
173 | // | ||
174 | void LLFloaterHtmlHelp::onClose( bool app_quitting ) | ||
175 | { | ||
176 | setVisible( false ); | ||
177 | } | ||
178 | |||
179 | //////////////////////////////////////////////////////////////////////////////// | ||
180 | // | ||
181 | void LLFloaterHtmlHelp::onClickClose( void* data ) | ||
182 | { | ||
183 | LLFloaterHtmlHelp* self = ( LLFloaterHtmlHelp* )data; | ||
184 | |||
185 | self->setVisible( false ); | ||
186 | } | ||
187 | |||
188 | //////////////////////////////////////////////////////////////////////////////// | ||
189 | // | ||
190 | void LLFloaterHtmlHelp::onClickBack( void* data ) | ||
191 | { | ||
192 | LLFloaterHtmlHelp* self = ( LLFloaterHtmlHelp* )data; | ||
193 | if ( self ) | ||
194 | { | ||
195 | if ( self->mWebBrowser ) | ||
196 | { | ||
197 | self->mWebBrowser->navigateBack(); | ||
198 | }; | ||
199 | }; | ||
200 | } | ||
201 | |||
202 | //////////////////////////////////////////////////////////////////////////////// | ||
203 | // | ||
204 | void LLFloaterHtmlHelp::onClickHome( void* data ) | ||
205 | { | ||
206 | LLFloaterHtmlHelp* self = ( LLFloaterHtmlHelp* )data; | ||
207 | if ( self ) | ||
208 | { | ||
209 | // get the home page URL (which can differ from the start URL) from XML and go there | ||
210 | LLWebBrowserCtrl* web_browser = LLUICtrlFactory::getWebBrowserCtrlByName( self, "html_help_browser" ); | ||
211 | if ( web_browser ) | ||
212 | { | ||
213 | web_browser->navigateHome(); | ||
214 | }; | ||
215 | }; | ||
216 | } | ||
217 | |||
218 | //////////////////////////////////////////////////////////////////////////////// | ||
219 | // | ||
220 | void LLFloaterHtmlHelp::onClickForward( void* data ) | ||
221 | { | ||
222 | LLFloaterHtmlHelp* self = ( LLFloaterHtmlHelp* )data; | ||
223 | if ( self ) | ||
224 | { | ||
225 | if ( self->mWebBrowser ) | ||
226 | { | ||
227 | self->mWebBrowser->navigateForward(); | ||
228 | }; | ||
229 | }; | ||
230 | } | ||
231 | |||
232 | //////////////////////////////////////////////////////////////////////////////// | ||
233 | // | ||
234 | void LLFloaterHtmlHelp::onStatusTextChange( const EventType& eventIn ) | ||
235 | { | ||
236 | mStatusTextContents = LLString( eventIn.getStringValue() ); | ||
237 | |||
238 | childSetText("status_text", mStatusTextContents); | ||
239 | } | ||
240 | |||
241 | //////////////////////////////////////////////////////////////////////////////// | ||
242 | // | ||
243 | void LLFloaterHtmlHelp::onLocationChange( const EventType& eventIn ) | ||
244 | { | ||
245 | llinfos << "MOZ> Location changed to " << eventIn.getStringValue() << llendl; | ||
246 | mCurrentUrl = LLString( eventIn.getStringValue() ); | ||
247 | } | ||
248 | |||
249 | //////////////////////////////////////////////////////////////////////////////// | ||
250 | // | ||
251 | // static | ||
252 | void LLHtmlHelp::show(void* url_string) | ||
253 | { | ||
254 | LLFloaterHtmlHelp::show(url_string); | ||
255 | } | ||
256 | |||
257 | // static | ||
258 | BOOL LLHtmlHelp::getFloaterOpened() | ||
259 | { | ||
260 | return LLFloaterHtmlHelp::sFloaterOpened; | ||
261 | } | ||
262 | |||
263 | #endif // LL_LIBXUL_ENABLED | ||
264 | |||