My Project
GUIWebBrowser.h
1 #pragma once
2 #include "GUIBase.h"
3 #include <string>
4 #include <list>
5 #include "WebBrowser/IBrowserMsgListener.h"
6 #include "util/mutex.h"
7 #include <boost/thread.hpp>
8 #include <boost/shared_ptr.hpp>
9 
10 using namespace std;
11 
12 namespace ParaEngine
13 {
14 class WebBrowser;
15 struct SpriteFontEntity;
16 struct AssetEntity;
31 {
32 public:
34 
36  // implementation of IAttributeFields
37 
39  virtual int GetAttributeClassID(){return ATTRIBUTE_CLASSID_CGUIWebBrowser;}
41  virtual const char* GetAttributeClassName(){static const char name[] = "CGUIWebBrowser"; return name;}
43  virtual const char* GetAttributeClassDescription(){static const char desc[] = ""; return desc;}
45  virtual int InstallFields(CAttributeClass* pClass, bool bOverride);
46 
47  ATTRIBUTE_METHOD(CGUIWebBrowser, Refresh_s) {cls->Refresh();return S_OK;}
48  ATTRIBUTE_METHOD(CGUIWebBrowser, GoBack_s) {cls->GoBack();return S_OK;}
49  ATTRIBUTE_METHOD(CGUIWebBrowser, GoForward_s) {cls->GoForward();return S_OK;}
50  ATTRIBUTE_METHOD(CGUIWebBrowser, Stop_s) {cls->Stop();return S_OK;}
51 
52  ATTRIBUTE_METHOD1(CGUIWebBrowser, GetContent_s, const char**) {*p1 = cls->GetContent().c_str(); return S_OK;}
53  ATTRIBUTE_METHOD1(CGUIWebBrowser, SetContent_s, const char*) {cls->SetContent(p1); return S_OK;}
54 
55  ATTRIBUTE_METHOD1(CGUIWebBrowser, SetFindText_s, const char*) {cls->FindText(p1); return S_OK;}
56 
57  ATTRIBUTE_METHOD1(CGUIWebBrowser, GetFindTextResult_s, int*) {*p1 = cls->GetLastFindTextResult(); return S_OK;}
58 
59 
61  static void GlobalFrameMove();
62 
67  virtual void SetTextA(const char* szText);
73  virtual void SetText(const char16_t* wszText);
74 
81  virtual int GetTextA(std::string& out);
87  virtual const char16_t* GetText();
88 
90  bool FindText(const std::string& sFindText);
92  int GetLastFindTextResult();
93 
95  void SetContent(const std::string& sContent);
97  const std::string& GetContent();
98 
99  void SetColor(DWORD color);
100  void SetTransparency(DWORD transparency);
101 
103  void Refresh();
104  void GoBack();
105  void GoForward();
106  void Stop();
107 
108  virtual void InitObject(const char * strObjectName, const char * alignment, int x, int y, int width, int height);
109  virtual void UpdateRects();
110  virtual HRESULT Render(GUIState* pGUIState ,float fElapsedTime);
112  virtual HRESULT RenderInBatch(GUIState* pGUIState);
113  virtual bool OnChange(const char* code=NULL);
114 
115  virtual void Clone(IObject* pobj)const;
116  virtual IObject* Clone()const;
117  virtual const IType* GetType()const{return m_type;}
118 
119  static void StaticInit();
120  CGUIWebBrowser(void);
121  virtual ~CGUIWebBrowser(void);
122 
123  virtual void OnWebPageLoaded();
124 
126  WebBrowser* CreateGetBrowser();
127 
128 public:
132  HRESULT StartWindowThread();
133  void DefaultWinThreadProc();
134 
136  bool MsgProcCustom(UINT message,WPARAM wParam,LPARAM lParam);
137 
139  bool PostWinThreadMessage(UINT message,WPARAM wParam,LPARAM lParam);
140 
142  void MoveWindow(int x, int y, int width, int height, bool bRepaint=true);
143 
145  void ShowBrowser(bool bShow = true);
146 protected:
147  static const IType* m_type;
149  static std::list<CGUIWebBrowser*> g_active_browsers;
151  std::u16string m_szText;
152  std::string m_szUTF8_Text;
154  std::string m_szCurrentURL;
155  bool m_bAutoSize;
156  HWND m_hBrowserHostWnd;
157  HWND m_hBrowserWnd;
158  int m_nWindowID;
159  WebBrowser* m_pWebBrowser;
160  int m_nWndX, m_nWndY, m_nWndWidth, m_nWndHeight;
163  bool m_bIsBrowserVisible;
164  bool m_bHasOnChangeEvent;
165 
166  // the default window thread ptr.
167  Boost_Thread_ptr_type m_win_thread;
168  ParaEngine::mutex m_win_thread_mutex;
169  bool m_bWindowCreated;
170  int m_nLastFindTextResult;
171  std::string m_sLastFindText;
172  std::string m_sLastWriteContent;
173 
174  std::string m_sLastGetContent;
175  std::string m_sContent;
176 
177  DWORD m_dwWinThreadID;
178 };
179 }
IType is for type information and validating It contains type information of an object.
Definition: Type.h:75
virtual int GetAttributeClassID()
attribute class ID should be identical, unless one knows how overriding rules work.
Definition: GUIWebBrowser.h:39
an attribute class is a collection of attribute fields.
Definition: AttributeClass.h:10
Definition: IBrowserMsgListener.h:9
different physics engine has different winding order.
Definition: EventBinding.h:32
This class represents a string inside a rectangular box in the screen coordinates Multiple Type_GUIWe...
Definition: GUIWebBrowser.h:30
base object for all 2D GUI objects (1) 2D GUI object are not tested against view frustum, instead it is controlled by visibility tag automatically or through user input.
Definition: GUIBase.h:54
static std::list< CGUIWebBrowser * > g_active_browsers
all active browsers that has already created window
Definition: GUIWebBrowser.h:149
base class for object, such as CBaseObject, IAttributeObject, GUI object.
Definition: PERef.h:287
std::u16string m_szText
Text to output to screen.
Definition: GUIWebBrowser.h:151
It&#39;s used as parameter to Render method of each GUI object.
Definition: GUIState.h:16
Definition: inftrees.h:24
bool m_bHasContent
whether the browser has content to show now
Definition: GUIWebBrowser.h:162
virtual const char * GetAttributeClassDescription()
a static string, describing the attribute class object
Definition: GUIWebBrowser.h:43
std::string m_szCurrentURL
current url updated automatically between page load.
Definition: GUIWebBrowser.h:154
cross platform mutex
Definition: mutex.h:95
Definition: WebBrowser.h:14
virtual const char * GetAttributeClassName()
a static string, describing the attribute class object&#39;s name
Definition: GUIWebBrowser.h:41