My Project
IHTMLRenderer.h
1 //-----------------------------------------------------------------------------
2 // Copyright (C) 2004 - 2007 ParaEngine Corporation, All Rights Reserved.
3 // Author: LiXizhi
4 // Email: LiXizhi@yeah.net
5 //-----------------------------------------------------------------------------
6 #pragma once
7 
9 // most of the interface is from uBrowser project. see. uBrowser.com
10 
11 #include <string>
12 #include <map>
13 
14 #define HTMLRENDERER_CLASS_ID 0x200A20
15 
16 namespace ParaEngine
17 {
18 
19  class ParaEmbeddedBrowser;
20  class ParaEmbeddedBrowserWindow;
21 
23  // data class that is passed with an event
25  {
26  public:
27  ParaEmbeddedBrowserWindowEvent( int eventWindowIdIn, std::string uriIn ) :
28  mEventWindowId( eventWindowIdIn ),
29  mEventUri( uriIn )
30  {
31  };
32 
33  // single int passed with the event - e.g. progress
34  ParaEmbeddedBrowserWindowEvent( int eventWindowIdIn, std::string uriIn, int intValIn ) :
35  mEventWindowId( eventWindowIdIn ),
36  mEventUri( uriIn ),
37  mIntVal( intValIn )
38  {
39  };
40 
41  // string passed with the event
42  ParaEmbeddedBrowserWindowEvent( int eventWindowIdIn, std::string uriIn, std::string stringValIn ) :
43  mEventWindowId( eventWindowIdIn ),
44  mEventUri( uriIn ),
45  mStringVal( stringValIn )
46  {
47  };
48 
49  // string and an int passed with the event
50  ParaEmbeddedBrowserWindowEvent( int eventWindowIdIn, std::string uriIn, std::string stringValIn, int intValIn ) :
51  mEventWindowId( eventWindowIdIn ),
52  mEventUri( uriIn ),
53  mStringVal( stringValIn ),
54  mIntVal( intValIn )
55  {
56  };
57 
58  // 4 ints passed (semantically as a rectangle but could be anything - didn't want to make a RECT type structure)
59  ParaEmbeddedBrowserWindowEvent( int eventWindowIdIn, std::string uriIn, int xIn, int yIn, int widthIn, int heightIn ) :
60  mEventWindowId( eventWindowIdIn ),
61  mEventUri( uriIn ),
62  mXVal( xIn ),
63  mYVal( yIn ),
64  mWidthVal( widthIn ),
65  mHeightVal( heightIn )
66  {
67  };
68 
70  {
71  };
72 
73  int getEventWindowId() const
74  {
75  return mEventWindowId;
76  };
77 
78  std::string getEventUri() const
79  {
80  return mEventUri;
81  };
82 
83  int getIntValue() const
84  {
85  return mIntVal;
86  };
87 
88  std::string getStringValue() const
89  {
90  return mStringVal;
91  };
92 
93  void getRectValue( int& xOut, int& yOut, int& widthOut, int& heightOut ) const
94  {
95  xOut = mXVal;
96  yOut = mYVal;
97  widthOut = mWidthVal;
98  heightOut = mHeightVal;
99  };
100 
101  private:
102  int mEventWindowId;
103  std::string mEventUri;
104  int mIntVal;
105  std::string mStringVal;
106  int mXVal;
107  int mYVal;
108  int mWidthVal;
109  int mHeightVal;
110  };
111 
113  // derive from this class and override these methods to observe these events
115  {
116  public:
117  virtual ~IEmbeddedBrowserWindowObserver() { };
119 
120  virtual void onPageChanged( const EventType& eventIn ) { };
121  virtual void onNavigateBegin( const EventType& eventIn ) { };
122  virtual void onNavigateComplete( const EventType& eventIn ) { };
123  virtual void onUpdateProgress( const EventType& eventIn ) { };
124  virtual void onStatusTextChange( const EventType& eventIn ) { };
125  virtual void onLocationChange( const EventType& eventIn ) { };
126  virtual void onClickLinkHref( const EventType& eventIn ) { };
127  };
128 
135  {
136  public:
138  virtual void DeleteThis()=0;
139 
140  // housekeeping
141  virtual bool init( std::string appBaseDirIn, std::string profileDirNameIn )=0;
142  virtual bool reset()=0;
143  virtual bool clearCache()=0;
144  virtual int getLastError()=0;
145  virtual const std::string getVersion()=0;
146  virtual void setBrowserAgentId( std::string idIn )=0;
147 
148  // browser window - creation/deletion, mutation etc.
149  virtual int createBrowserWindow( void* nativeWindowHandleIn, int browserWindowWidthIn, int browserWindowHeightIn )=0;
150  virtual bool destroyBrowserWindow( int browserWindowIdIn )=0;
151  virtual bool setSize( int browserWindowIdIn, int widthIn, int heightIn )=0;
152  virtual bool scrollByLines( int browserWindowIdIn, int linesIn )=0;
153  virtual bool setBackgroundColor( int browserWindowIdIn, const int redIn, const int greenIn, const int blueIn )=0;
154  virtual bool setEnabled( int browserWindowIdIn, bool enabledIn )=0;
155 
156  // add/remove yourself as an observer on browser events - see IEmbeddedBrowserWindowObserver declaration
157  virtual bool addObserver( int browserWindowIdIn, IEmbeddedBrowserWindowObserver* subjectIn )=0;
158  virtual bool remObserver( int browserWindowIdIn, IEmbeddedBrowserWindowObserver* subjectIn )=0;
159 
160  // navigation - self explanatory
161  virtual bool navigateTo( int browserWindowIdIn, const std::string uriIn )=0;
162  virtual bool navigateStop( int browserWindowIdIn )=0;
163  virtual bool canNavigateBack( int browserWindowIdIn )=0;
164  virtual bool navigateBack( int browserWindowIdIn )=0;
165  virtual bool canNavigateForward( int browserWindowIdIn )=0;
166  virtual bool navigateForward( int browserWindowIdIn )=0;
167 
168  // access to rendered bitmap data
169  virtual const unsigned char* grabBrowserWindow( int browserWindowIdIn )=0; // renders page to memory and returns pixels
170  virtual const unsigned char* getBrowserWindowPixels( int browserWindowIdIn )=0; // just returns pixels - no render
171  virtual const int getBrowserWidth( int browserWindowIdIn )=0; // current browser width (can vary slightly after page is rendered)
172  virtual const int getBrowserHeight( int browserWindowIdIn )=0; // current height
173  virtual const int getBrowserDepth( int browserWindowIdIn )=0; // depth in bytes
174  virtual const int getBrowserRowSpan( int browserWindowIdIn )=0; // width in pixels * depth in bytes
175 
176  // mouse/keyboard interaction
177  virtual bool mouseDown( int browserWindowIdIn, int xPosIn, int yPosIn )=0; // send a mouse down event to a browser window at given XY in browser space
178  virtual bool mouseUp( int browserWindowIdIn, int xPosIn, int yPosIn )=0; // send a mouse up event to a browser window at given XY in browser space
179  virtual bool mouseMove( int browserWindowIdIn, int xPosIn, int yPosIn )=0; // send a mouse move event to a browser window at given XY in browser space
180  virtual bool keyPress( int browserWindowIdIn, int keyCodeIn )=0; // send a key press event to a browser window
181  virtual bool focusBrowser( int browserWindowIdIn, bool focusBrowserIn )=0; // set/remove focus to given browser window
182 
183  // accessor/mutator for scheme that browser doesn't follow - e.g. secondlife.com://
184  virtual void setNoFollowScheme( int browserWindowIdIn, std::string schemeIn )=0;
185  virtual std::string getNoFollowScheme( int browserWindowIdIn )=0;
186  };
187 }
Definition: IHTMLRenderer.h:24
different physics engine has different winding order.
Definition: EventBinding.h:32
Definition: IHTMLRenderer.h:114
NPL interface of a XML Web service client proxy this class is implemented by ParaEngine.Net plug-in.
Definition: IHTMLRenderer.h:134
EventType
event type
Definition: PEtypes.h:184