Panda3D
 All Classes Functions Variables Enumerations
awWebView.h
1 // Filename: awWebCore.h
2 // Created by: rurbino (12Oct09)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 #ifndef AWWEBVIEW_H
15 #define AWWEBVIEW_H
16 
17 #include "pandabase.h"
18 #include "typedReferenceCount.h"
19 #include "luse.h"
20 
21 #include "awesomium_includes.h"
22 
23 class WebViewListener;
24 
25 ////////////////////////////////////////////////////////////////////
26 // Class : AwWebView
27 // Description : Thin bindings, wraps a WebView * returned from WebCore.createWebView
28 ////////////////////////////////////////////////////////////////////
29 class EXPCL_PANDAAWESOMIUM AwWebView : public TypedReferenceCount{
30 PUBLISHED:
31 
32  /**
33  * Mouse button enumerations, used with WebView::injectMouseDown
34  * and WebView::injectMouseUp
35  */
36  enum MouseButton {
37  LEFT_MOUSE_BTN,
38  MIDDLE_MOUSE_BTN,
39  RIGHT_MOUSE_BTN
40  };
41 
42  /**
43  * A simple rectangle class, used with WebView::render
44  */
45  struct Rect {
46  int x, y, width, height;
47 
48  Rect();
49  Rect(int x, int y, int width, int height);
50  bool isEmpty() const;
51  };
52 
53 
54 PUBLISHED:
55  AwWebView(Awesomium::WebView * webView);
56 
57  virtual ~AwWebView();
58 
59  INLINE void destroy(void);
60 
61  INLINE void setListener(Awesomium::WebViewListener * listener);
62 
63  INLINE Awesomium::WebViewListener* getListener();
64 
65  // VC7 linker doesn't like wstring from VS2008, hence using the all regular string version
66  void loadURL2(const string& url, const string& frameName ="", const string& username="" , const string& password="");
67 
68  // VC7 linker doesn't like wstring from VS2008, hence using the all regular string version
69  void loadHTML2(const std::string& html, const std::string& frameName = "");
70 
71  // VC7 linker doesn't like wstring from VS2008, hence using the all regular string version
72  void loadFile2(const std::string& file, const std::string& frameName = "" );
73 
74  INLINE void goToHistoryOffset(int offset);
75 
76  // VC7 linker doesn't like wstring from VS2008, hence using the all regular string version
77  INLINE void executeJavascript2(const std::string& javascript, const std::string& frameName = "" );
78 
79  INLINE Awesomium::FutureJSValue executeJavascriptWithResult2(const std::string& javascript, const std::string& frameName = "");
80 
81  INLINE void setProperty(const std::string& name, const Awesomium::JSValue& value);
82 
83  INLINE void setCallback(const std::string& name);
84 
85  INLINE bool isDirty();
86 
87  INLINE void render(size_t destination, int destRowSpan, int destDepth);
88 
89  void render(size_t destination, int destRowSpan, int destDepth, AwWebView::Rect * renderedRect);
90 
91  void injectMouseMove(int x, int y);
92 
93  void injectMouseDown(AwWebView::MouseButton button);
94 
95  INLINE void injectMouseUp(AwWebView::MouseButton button);
96 
97  INLINE void injectMouseWheelXY(int scrollAmountX, int scrollAmountY);
98 
99  INLINE void injectMouseWheel(int scrollAmountY) {
100  injectMouseWheelXY(0, scrollAmountY);
101  }
102 
103  INLINE void injectKeyEvent(bool press, int modifiers, int windowsCode, int nativeCode=0);
104 
105 private:
106  Awesomium::WebView * _myWebView;
107 
108 public:
109  static TypeHandle get_class_type() {
110  return _type_handle;
111  }
112  static void init_type() {
113  TypedReferenceCount::init_type();
114  register_type(_type_handle, "AwWebView",
115  TypedReferenceCount::get_class_type());
116  }
117  virtual TypeHandle get_type() const {
118  return get_class_type();
119  }
120  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
121 
122 private:
123  static TypeHandle _type_handle;
124 };
125 
126 #include "awWebView.I"
127 
128 #endif
This class is just used as a convenient namespace for grouping all of these handy functions that retu...
Definition: mouseButton.h:28
MouseButton
Mouse button enumerations, used with WebView::injectMouseDown and WebView::injectMouseUp.
Definition: awWebView.h:36
A simple rectangle class, used with WebView::render.
Definition: awWebView.h:45
A base class for things which need to inherit from both TypedObject and from ReferenceCount.
Thin bindings, wraps a WebView * returned from WebCore.createWebView.
Definition: awWebView.h:29
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85