Panda3D
 All Classes Functions Variables Enumerations
awWebView.h
00001 // Filename: awWebCore.h
00002 // Created by:  rurbino (12Oct09)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 #ifndef AWWEBVIEW_H
00015 #define AWWEBVIEW_H
00016 
00017 #include "pandabase.h"
00018 #include "typedReferenceCount.h"
00019 #include "luse.h"
00020 
00021 #include "awesomium_includes.h"
00022 
00023 class WebViewListener;
00024 
00025 ////////////////////////////////////////////////////////////////////
00026 //       Class : AwWebView
00027 // Description : Thin bindings, wraps a WebView * returned from WebCore.createWebView
00028 ////////////////////////////////////////////////////////////////////
00029 class EXPCL_PANDAAWESOMIUM AwWebView : public TypedReferenceCount{
00030 PUBLISHED:
00031 
00032   /**
00033   * Mouse button enumerations, used with WebView::injectMouseDown 
00034   * and WebView::injectMouseUp
00035   */
00036   enum MouseButton {
00037     LEFT_MOUSE_BTN,
00038     MIDDLE_MOUSE_BTN,
00039     RIGHT_MOUSE_BTN
00040   };
00041 
00042   /**
00043    * A simple rectangle class, used with WebView::render
00044    */
00045   struct Rect {
00046     int x, y, width, height;
00047     
00048     Rect();
00049     Rect(int x, int y, int width, int height);
00050     bool isEmpty() const;
00051   };
00052 
00053 
00054 PUBLISHED:
00055   AwWebView(Awesomium::WebView * webView);
00056   
00057   virtual ~AwWebView();
00058   
00059   INLINE void destroy(void);
00060   
00061   INLINE void setListener(Awesomium::WebViewListener * listener);
00062 
00063   INLINE Awesomium::WebViewListener* getListener();
00064   
00065   // VC7 linker doesn't like wstring from VS2008, hence using the all regular string version
00066   void loadURL2(const string& url, const string& frameName ="", const string& username="" , const string& password="");
00067   
00068   // VC7 linker doesn't like wstring from VS2008, hence using the all regular string version
00069   void loadHTML2(const std::string& html, const std::string& frameName = "");
00070   
00071   // VC7 linker doesn't like wstring from VS2008, hence using the all regular string version
00072   void loadFile2(const std::string& file, const std::string& frameName = "" );
00073   
00074   INLINE void goToHistoryOffset(int offset);
00075 
00076   // VC7 linker doesn't like wstring from VS2008, hence using the all regular string version
00077   INLINE void executeJavascript2(const std::string& javascript, const std::string& frameName = "" );
00078 
00079   INLINE Awesomium::FutureJSValue executeJavascriptWithResult2(const std::string& javascript, const std::string& frameName = "");
00080 
00081   INLINE void setProperty(const std::string& name, const Awesomium::JSValue& value);
00082 
00083   INLINE void setCallback(const std::string& name);
00084 
00085   INLINE bool isDirty();
00086 
00087   INLINE void render(size_t destination, int destRowSpan, int destDepth);
00088 
00089   void render(size_t destination, int destRowSpan, int destDepth, AwWebView::Rect * renderedRect);
00090 
00091   void injectMouseMove(int x, int y);
00092 
00093   void injectMouseDown(AwWebView::MouseButton button);
00094 
00095   INLINE void injectMouseUp(AwWebView::MouseButton button);
00096 
00097   INLINE void injectMouseWheelXY(int scrollAmountX, int scrollAmountY);
00098 
00099   INLINE void injectMouseWheel(int scrollAmountY) {
00100     injectMouseWheelXY(0, scrollAmountY);
00101   }
00102 
00103   INLINE void injectKeyEvent(bool press, int modifiers, int windowsCode, int nativeCode=0);
00104   
00105 private:
00106   Awesomium::WebView * _myWebView;
00107 
00108 public:
00109   static TypeHandle get_class_type() {
00110     return _type_handle;
00111   }
00112   static void init_type() {
00113     TypedReferenceCount::init_type();
00114     register_type(_type_handle, "AwWebView",
00115                   TypedReferenceCount::get_class_type());
00116   }
00117   virtual TypeHandle get_type() const {
00118     return get_class_type();
00119   }
00120   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00121 
00122 private:
00123   static TypeHandle _type_handle;
00124 };
00125 
00126 #include "awWebView.I"
00127 
00128 #endif
 All Classes Functions Variables Enumerations