aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llwebbrowserctrl.h
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/llwebbrowserctrl.h
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/llwebbrowserctrl.h')
-rw-r--r--linden/indra/newview/llwebbrowserctrl.h257
1 files changed, 257 insertions, 0 deletions
diff --git a/linden/indra/newview/llwebbrowserctrl.h b/linden/indra/newview/llwebbrowserctrl.h
new file mode 100644
index 0000000..57c72c5
--- /dev/null
+++ b/linden/indra/newview/llwebbrowserctrl.h
@@ -0,0 +1,257 @@
1/**
2 * @file llwebbrowserctrl.h
3 * @brief Web browser UI 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#ifndef LL_LLWEBBROWSERCTRL_H
29#define LL_LLWEBBROWSERCTRL_H
30
31////////////////////////////////////////////////////////////////////////////////
32// data class that is passed with an event
33class LLWebBrowserCtrlEvent
34{
35 public:
36 LLWebBrowserCtrlEvent()
37 {
38 };
39
40 LLWebBrowserCtrlEvent( int intValIn ) :
41 mIntVal( intValIn )
42 {
43 };
44
45 LLWebBrowserCtrlEvent( std::string stringValIn ) :
46 mStringVal( stringValIn )
47 {
48 };
49
50 virtual ~LLWebBrowserCtrlEvent()
51 {
52 };
53
54 int getIntValue() const
55 {
56 return mIntVal;
57 };
58
59 std::string getStringValue() const
60 {
61 return mStringVal;
62 };
63
64 private:
65 int mIntVal;
66 std::string mStringVal;
67};
68
69////////////////////////////////////////////////////////////////////////////////
70// Override these methods to observe web browser control events
71// (they are chained and fired after observing LLMozLibEvents)
72class LLWebBrowserCtrlObserver
73{
74 public:
75 virtual ~LLWebBrowserCtrlObserver() { };
76
77 typedef LLWebBrowserCtrlEvent EventType;
78 virtual void onNavigateBegin( const EventType& eventIn ) { };
79 virtual void onNavigateComplete( const EventType& eventIn ) { };
80 virtual void onUpdateProgress( const EventType& eventIn ) { };
81 virtual void onStatusTextChange( const EventType& eventIn ) { };
82 virtual void onLocationChange( const EventType& eventIn ) { };
83 virtual void onClickLinkHref( const EventType& eventIn ) { };
84 virtual void onClickLinkSecondLife( const EventType& eventIn ) { };
85};
86
87#if LL_LIBXUL_ENABLED
88
89#include "lluictrl.h"
90#include "llframetimer.h"
91#include "lldynamictexture.h"
92#include "llmozlib.h"
93
94class LLViewBorder;
95class LLWebBrowserTexture;
96
97///////////////////////////////////////////////////////////////////////////////
98// manages the process of storing and emitting events that the consumer
99// of the embedding class can observe
100template< class T >
101class LLWebBrowserCtrlEventEmitter
102{
103 public:
104 LLWebBrowserCtrlEventEmitter() { };
105 ~LLWebBrowserCtrlEventEmitter() { };
106
107 typedef typename T::EventType EventType;
108 typedef std::list< T* > ObserverContainer;
109 typedef void( T::*observerMethod )( const EventType& );
110
111 ///////////////////////////////////////////////////////////////////////////////
112 //
113 bool addObserver( T* observerIn )
114 {
115 if ( ! observerIn )
116 return false;
117
118 if ( std::find( observers.begin(), observers.end(), observerIn ) != observers.end() )
119 return false;
120
121 observers.push_back( observerIn );
122
123 return true;
124 };
125
126 ///////////////////////////////////////////////////////////////////////////////
127 //
128 bool remObserver( T* observerIn )
129 {
130 if ( ! observerIn )
131 return false;
132
133 observers.remove( observerIn );
134
135 return true;
136 };
137
138 ///////////////////////////////////////////////////////////////////////////////
139 //
140 void update( observerMethod method, const EventType& msgIn )
141 {
142 typename std::list< T* >::iterator iter = observers.begin();
143
144 while( iter != observers.end() )
145 {
146 ( ( *iter )->*method )( msgIn );
147
148 ++iter;
149 };
150 };
151
152 protected:
153 ObserverContainer observers;
154};
155
156////////////////////////////////////////////////////////////////////////////////
157//
158class LLWebBrowserCtrl :
159 public LLUICtrl,
160 public LLEmbeddedBrowserWindowObserver
161{
162 public:
163 LLWebBrowserCtrl( const std::string& name, const LLRect& rect );
164 virtual ~LLWebBrowserCtrl();
165
166 void setBorderVisible( BOOL border_visible );
167
168 static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
169
170 // for XML construction
171 virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_WEBBROWSER; }
172 virtual LLString getWidgetTag() const { return LL_WEB_BROWSER_CTRL_TAG; }
173
174 // handle mouse related methods
175 virtual BOOL handleHover( S32 x, S32 y, MASK mask );
176 virtual BOOL handleMouseUp( S32 x, S32 y, MASK mask );
177 virtual BOOL handleMouseDown( S32 x, S32 y, MASK mask );
178 virtual BOOL handleScrollWheel( S32 x, S32 y, S32 clicks );
179
180 // navigation
181 void navigateTo( std::string urlIn );
182 void navigateBack();
183 void navigateHome();
184 void navigateForward();
185 bool canNavigateBack();
186 bool canNavigateForward();
187 void setOpenInExternalBrowser( bool valIn );
188 void setHomePageUrl( const std::string urlIn );
189 std::string getHomePageUrl();
190
191 // accessor/mutator for flag that indicates if frequent updates to texture happen
192 bool getFrequentUpdates() { return mFrequentUpdates; };
193 void setFrequentUpdates( bool frequentUpdatesIn ) { mFrequentUpdates = frequentUpdatesIn; };
194
195 // over-rides
196 virtual BOOL handleKey( KEY key, MASK mask, BOOL called_from_parent );
197 virtual void reshape( S32 width, S32 height, BOOL called_from_parent );
198 virtual void draw();
199 virtual void onVisibilityChange ( BOOL curVisibilityIn );
200
201 // focus overrides
202 void onFocusLost();
203 void onFocusReceived();
204
205 // observer interface
206 bool addObserver( LLWebBrowserCtrlObserver* subjectIn );
207 bool remObserver( LLWebBrowserCtrlObserver* subjectIn );
208
209 // LLMozlib observer overrides
210 virtual void onNavigateBegin( const EventType& eventIn );
211 virtual void onNavigateComplete( const EventType& eventIn );
212 virtual void onUpdateProgress( const EventType& eventIn );
213 virtual void onStatusTextChange( const EventType& eventIn );
214 virtual void onLocationChange( const EventType& eventIn );
215 virtual void onClickLinkHref( const EventType& eventIn );
216 virtual void onClickLinkSecondLife( const EventType& eventIn );
217
218 private:
219 LLWebBrowserCtrlEventEmitter< LLWebBrowserCtrlObserver > mEventEmitter;
220 const S32 mTextureDepthBytes;
221 int mEmbeddedBrowserWindowId;
222 LLWebBrowserTexture* mWebBrowserImage;
223 LLViewBorder* mBorder;
224 bool mFrequentUpdates;
225 bool mOpenLinksInExternalBrowser;
226 std::string mHomePageUrl;
227};
228
229////////////////////////////////////////////////////////////////////////////////
230//
231class LLWebBrowserTexture : public LLDynamicTexture
232{
233 public:
234 LLWebBrowserTexture::LLWebBrowserTexture( S32 width, S32 height, LLWebBrowserCtrl* browserCtrl, int browserWindow );
235 virtual ~LLWebBrowserTexture();
236
237 virtual void preRender( BOOL clear_depth = TRUE ) {};
238 virtual void postRender( BOOL success ) {};
239 virtual BOOL render();
240
241 S32 getBrowserWidth();
242 S32 getBrowserHeight();
243
244 void resize( S32 new_width, S32 new_height );
245
246 protected:
247 S32 mBrowserWidth;
248 S32 mBrowserHeight;
249 S32 mLastBrowserDepth;
250 LLFrameTimer mElapsedTime;
251 LLWebBrowserCtrl* mWebBrowserCtrl;
252 int mEmbeddedBrowserWindowId;
253};
254
255#endif // // LL_LIBXUL_ENABLED
256
257#endif // LL_LLWEBBROWSERCTRL_H \ No newline at end of file