diff options
Diffstat (limited to 'linden/indra/newview/llfloaterhtmlhelp.cpp')
-rw-r--r-- | linden/indra/newview/llfloaterhtmlhelp.cpp | 328 |
1 files changed, 0 insertions, 328 deletions
diff --git a/linden/indra/newview/llfloaterhtmlhelp.cpp b/linden/indra/newview/llfloaterhtmlhelp.cpp deleted file mode 100644 index 6cb6c0f..0000000 --- a/linden/indra/newview/llfloaterhtmlhelp.cpp +++ /dev/null | |||
@@ -1,328 +0,0 @@ | |||
1 | /** | ||
2 | * @file llfloaterhtmlhelp.cpp | ||
3 | * @brief HTML Help floater - uses embedded web browser control | ||
4 | * | ||
5 | * $LicenseInfo:firstyear=2006&license=viewergpl$ | ||
6 | * | ||
7 | * Copyright (c) 2006-2008, Linden Research, Inc. | ||
8 | * | ||
9 | * Second Life Viewer Source Code | ||
10 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
11 | * to you under the terms of the GNU General Public License, version 2.0 | ||
12 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
13 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
14 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
15 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
16 | * | ||
17 | * There are special exceptions to the terms and conditions of the GPL as | ||
18 | * it is applied to this Source Code. View the full text of the exception | ||
19 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
20 | * online at http://secondlife.com/developers/opensource/flossexception | ||
21 | * | ||
22 | * By copying, modifying or distributing this software, you acknowledge | ||
23 | * that you have read and understood your obligations described above, | ||
24 | * and agree to abide by those obligations. | ||
25 | * | ||
26 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
27 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
28 | * COMPLETENESS OR PERFORMANCE. | ||
29 | * $/LicenseInfo$ | ||
30 | */ | ||
31 | |||
32 | #include "llviewerprecompiledheaders.h" | ||
33 | |||
34 | #include "llfloaterhtmlhelp.h" | ||
35 | |||
36 | #include "llvieweruictrlfactory.h" | ||
37 | #include "llwebbrowserctrl.h" | ||
38 | #include "llviewerwindow.h" | ||
39 | #include "llviewercontrol.h" | ||
40 | #include "llweb.h" | ||
41 | #include "llui.h" | ||
42 | |||
43 | #if LL_LIBXUL_ENABLED | ||
44 | |||
45 | LLViewerHtmlHelp gViewerHtmlHelp; | ||
46 | |||
47 | class LLFloaterHtmlHelp : | ||
48 | public LLFloater, | ||
49 | public LLWebBrowserCtrlObserver | ||
50 | { | ||
51 | public: | ||
52 | LLFloaterHtmlHelp(std::string start_url, std::string title); | ||
53 | virtual ~LLFloaterHtmlHelp(); | ||
54 | |||
55 | virtual void onClose( bool app_quitting ); | ||
56 | virtual void draw(); | ||
57 | |||
58 | static void show(std::string url, std::string title); | ||
59 | static void onClickBack( void* data ); | ||
60 | static void onClickHome( void* data ); | ||
61 | static void onClickForward( void* data ); | ||
62 | static void onClickClose( void* data ); | ||
63 | |||
64 | // browser observer impls | ||
65 | virtual void onStatusTextChange( const EventType& eventIn ); | ||
66 | virtual void onLocationChange( const EventType& eventIn ); | ||
67 | |||
68 | // used for some stats logging - will be removed at some point | ||
69 | static BOOL sFloaterOpened; | ||
70 | |||
71 | static void onClickF1HelpLoadURL(S32 option, void* userdata); | ||
72 | |||
73 | protected: | ||
74 | LLWebBrowserCtrl* mWebBrowser; | ||
75 | static LLFloaterHtmlHelp* sInstance; | ||
76 | LLButton* mBackButton; | ||
77 | LLButton* mForwardButton; | ||
78 | LLButton* mCloseButton; | ||
79 | LLTextBox* mStatusText; | ||
80 | LLString mStatusTextContents; | ||
81 | LLString mCurrentUrl; | ||
82 | }; | ||
83 | |||
84 | LLFloaterHtmlHelp* LLFloaterHtmlHelp::sInstance = 0; | ||
85 | |||
86 | BOOL LLFloaterHtmlHelp::sFloaterOpened = FALSE; | ||
87 | |||
88 | //////////////////////////////////////////////////////////////////////////////// | ||
89 | // | ||
90 | LLFloaterHtmlHelp::LLFloaterHtmlHelp(std::string start_url, std::string title) | ||
91 | : LLFloater( "HTML Help" ), | ||
92 | mWebBrowser( 0 ), | ||
93 | mStatusTextContents( "" ), | ||
94 | mCurrentUrl( "" ) | ||
95 | { | ||
96 | sInstance = this; | ||
97 | |||
98 | // create floater from its XML definition | ||
99 | gUICtrlFactory->buildFloater( this, "floater_html_help.xml" ); | ||
100 | |||
101 | childSetAction("back_btn", onClickBack, this); | ||
102 | childSetAction("home_btn", onClickHome, this); | ||
103 | childSetAction("forward_btn", onClickForward, this); | ||
104 | |||
105 | if (!title.empty()) | ||
106 | { | ||
107 | setTitle(title); | ||
108 | } | ||
109 | |||
110 | mWebBrowser = LLViewerUICtrlFactory::getWebBrowserByName(this, "html_help_browser" ); | ||
111 | if ( mWebBrowser ) | ||
112 | { | ||
113 | // observe browser control events | ||
114 | mWebBrowser->addObserver( this ); | ||
115 | |||
116 | if (start_url != "") | ||
117 | { | ||
118 | mWebBrowser->navigateTo( start_url ); | ||
119 | } | ||
120 | else | ||
121 | { | ||
122 | // if the last page we were at before the client was closed is valid, go there and | ||
123 | // override what is in the XML file | ||
124 | // (not when the window was closed - it's only ever hidden - not closed) | ||
125 | LLString lastPageUrl = gSavedSettings.getString( "HtmlHelpLastPage" ); | ||
126 | if ( lastPageUrl != "" ) | ||
127 | { | ||
128 | mWebBrowser->navigateTo( lastPageUrl ); | ||
129 | }; | ||
130 | } | ||
131 | }; | ||
132 | } | ||
133 | |||
134 | //////////////////////////////////////////////////////////////////////////////// | ||
135 | // | ||
136 | LLFloaterHtmlHelp::~LLFloaterHtmlHelp() | ||
137 | { | ||
138 | // stop observing browser events | ||
139 | if ( mWebBrowser ) | ||
140 | { | ||
141 | mWebBrowser->remObserver( this ); | ||
142 | }; | ||
143 | |||
144 | // save position of floater | ||
145 | gSavedSettings.setRect( "HtmlHelpRect", mRect ); | ||
146 | |||
147 | // save the location we were at when SL closed | ||
148 | gSavedSettings.setString( "HtmlHelpLastPage", mCurrentUrl ); | ||
149 | |||
150 | sInstance = 0; | ||
151 | } | ||
152 | |||
153 | //////////////////////////////////////////////////////////////////////////////// | ||
154 | // virtual | ||
155 | void LLFloaterHtmlHelp::draw() | ||
156 | { | ||
157 | // enable/disable buttons depending on state | ||
158 | if ( mWebBrowser ) | ||
159 | { | ||
160 | bool enable_back = mWebBrowser->canNavigateBack(); | ||
161 | childSetEnabled( "back_btn", enable_back ); | ||
162 | |||
163 | bool enable_forward = mWebBrowser->canNavigateForward(); | ||
164 | childSetEnabled( "forward_btn", enable_forward ); | ||
165 | }; | ||
166 | |||
167 | LLFloater::draw(); | ||
168 | } | ||
169 | |||
170 | //////////////////////////////////////////////////////////////////////////////// | ||
171 | // | ||
172 | void LLFloaterHtmlHelp::show(std::string url, std::string title) | ||
173 | { | ||
174 | gViewerWindow->alertXml("ClickOpenF1Help", onClickF1HelpLoadURL, (void*) NULL); | ||
175 | |||
176 | // switching this out for the moment - will come back later | ||
177 | // want it still to be compiled so not using comments of #if 0 | ||
178 | if ( false ) | ||
179 | { | ||
180 | sFloaterOpened = true; | ||
181 | |||
182 | if ( sInstance ) | ||
183 | { | ||
184 | if (sInstance->mWebBrowser) | ||
185 | { | ||
186 | sInstance->mWebBrowser->navigateTo(url); | ||
187 | } | ||
188 | sInstance->setVisibleAndFrontmost(); | ||
189 | return; | ||
190 | } | ||
191 | |||
192 | LLFloaterHtmlHelp* self = new LLFloaterHtmlHelp(url, title); | ||
193 | |||
194 | // reposition floater from saved settings | ||
195 | LLRect rect = gSavedSettings.getRect( "HtmlHelpRect" ); | ||
196 | self->reshape( rect.getWidth(), rect.getHeight(), FALSE ); | ||
197 | self->setRect( rect ); | ||
198 | }; | ||
199 | } | ||
200 | |||
201 | // static | ||
202 | void LLFloaterHtmlHelp::onClickF1HelpLoadURL(S32 option, void* userdata) | ||
203 | { | ||
204 | if (option == 0) | ||
205 | { | ||
206 | // choose HELP url based on selected language - default to english language support page | ||
207 | LLString lang = LLUI::sConfigGroup->getString("Language"); | ||
208 | |||
209 | // this sucks but there isn't a way to grab an arbitrary string from an XML file | ||
210 | // (using llcontroldef strings causes problems if string don't exist) | ||
211 | LLString help_url( "http://secondlife.com/support" ); | ||
212 | if ( lang == "ja" ) | ||
213 | help_url = "http://help.secondlife.com/jp"; | ||
214 | else | ||
215 | if ( lang == "ko" ) | ||
216 | help_url = "http://help.secondlife.com/kr"; | ||
217 | else | ||
218 | if ( lang == "pt" ) | ||
219 | help_url = "http://help.secondlife.com/pt"; | ||
220 | else | ||
221 | if ( lang == "de" ) | ||
222 | help_url = "http://de.secondlife.com/support"; | ||
223 | |||
224 | LLWeb::loadURL( help_url ); | ||
225 | }; | ||
226 | } | ||
227 | |||
228 | //////////////////////////////////////////////////////////////////////////////// | ||
229 | // | ||
230 | void LLFloaterHtmlHelp::onClose( bool app_quitting ) | ||
231 | { | ||
232 | setVisible( false ); | ||
233 | } | ||
234 | |||
235 | //////////////////////////////////////////////////////////////////////////////// | ||
236 | // | ||
237 | void LLFloaterHtmlHelp::onClickClose( void* data ) | ||
238 | { | ||
239 | LLFloaterHtmlHelp* self = ( LLFloaterHtmlHelp* )data; | ||
240 | |||
241 | self->setVisible( false ); | ||
242 | } | ||
243 | |||
244 | //////////////////////////////////////////////////////////////////////////////// | ||
245 | // | ||
246 | void LLFloaterHtmlHelp::onClickBack( void* data ) | ||
247 | { | ||
248 | LLFloaterHtmlHelp* self = ( LLFloaterHtmlHelp* )data; | ||
249 | if ( self ) | ||
250 | { | ||
251 | if ( self->mWebBrowser ) | ||
252 | { | ||
253 | self->mWebBrowser->navigateBack(); | ||
254 | }; | ||
255 | }; | ||
256 | } | ||
257 | |||
258 | //////////////////////////////////////////////////////////////////////////////// | ||
259 | // | ||
260 | void LLFloaterHtmlHelp::onClickHome( void* data ) | ||
261 | { | ||
262 | LLFloaterHtmlHelp* self = ( LLFloaterHtmlHelp* )data; | ||
263 | if ( self ) | ||
264 | { | ||
265 | // get the home page URL (which can differ from the start URL) from XML and go there | ||
266 | LLWebBrowserCtrl* web_browser = LLUICtrlFactory::getWebBrowserCtrlByName( self, "html_help_browser" ); | ||
267 | if ( web_browser ) | ||
268 | { | ||
269 | web_browser->navigateHome(); | ||
270 | }; | ||
271 | }; | ||
272 | } | ||
273 | |||
274 | //////////////////////////////////////////////////////////////////////////////// | ||
275 | // | ||
276 | void LLFloaterHtmlHelp::onClickForward( void* data ) | ||
277 | { | ||
278 | LLFloaterHtmlHelp* self = ( LLFloaterHtmlHelp* )data; | ||
279 | if ( self ) | ||
280 | { | ||
281 | if ( self->mWebBrowser ) | ||
282 | { | ||
283 | self->mWebBrowser->navigateForward(); | ||
284 | }; | ||
285 | }; | ||
286 | } | ||
287 | |||
288 | //////////////////////////////////////////////////////////////////////////////// | ||
289 | // | ||
290 | void LLFloaterHtmlHelp::onStatusTextChange( const EventType& eventIn ) | ||
291 | { | ||
292 | mStatusTextContents = LLString( eventIn.getStringValue() ); | ||
293 | |||
294 | childSetText("status_text", mStatusTextContents); | ||
295 | } | ||
296 | |||
297 | //////////////////////////////////////////////////////////////////////////////// | ||
298 | // | ||
299 | void LLFloaterHtmlHelp::onLocationChange( const EventType& eventIn ) | ||
300 | { | ||
301 | llinfos << "MOZ> Location changed to " << eventIn.getStringValue() << llendl; | ||
302 | mCurrentUrl = LLString( eventIn.getStringValue() ); | ||
303 | } | ||
304 | |||
305 | //////////////////////////////////////////////////////////////////////////////// | ||
306 | // | ||
307 | LLViewerHtmlHelp::LLViewerHtmlHelp() | ||
308 | { | ||
309 | LLUI::setHtmlHelp(this); | ||
310 | } | ||
311 | |||
312 | LLViewerHtmlHelp::~LLViewerHtmlHelp() | ||
313 | { | ||
314 | LLUI::setHtmlHelp(NULL); | ||
315 | } | ||
316 | |||
317 | void LLViewerHtmlHelp::show(std::string url, std::string title) | ||
318 | { | ||
319 | LLFloaterHtmlHelp::show(url, title); | ||
320 | } | ||
321 | |||
322 | BOOL LLViewerHtmlHelp::getFloaterOpened() | ||
323 | { | ||
324 | return LLFloaterHtmlHelp::sFloaterOpened; | ||
325 | } | ||
326 | |||
327 | #endif // LL_LIBXUL_ENABLED | ||
328 | |||