Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

160 lines
4.4 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef _HTMLWINDOW_H_
  8. #define _HTMLWINDOW_H_
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #ifdef WIN32
  13. #include <exdispid.h>
  14. #include <olectl.h>
  15. #include <exdisp.h>
  16. #include <vgui/vgui.h>
  17. #include <vgui/IHTML.h>
  18. #include <vgui/IImage.h>
  19. #if defined ( GAMEUI_EXPORTS )
  20. #include <vgui/IPanel.h>
  21. #include <vgui_controls/Controls.h>
  22. #else
  23. #include "VPanel.h"
  24. #endif
  25. #if defined ( GAMEUI_EXPORTS )
  26. #include "../vgui2/src/Memorybitmap.h"
  27. #else
  28. #include "Memorybitmap.h"
  29. #endif
  30. struct IHTMLElement;
  31. class HtmlWindow : public vgui::IHTML, vgui::IHTMLEvents
  32. {
  33. public:
  34. HtmlWindow(vgui::IHTMLEvents *events, vgui::VPANEL c, HWND parent, bool AllowJavaScript, bool DirectToHWND);
  35. virtual ~HtmlWindow();
  36. virtual void OpenURL(const char *);
  37. virtual bool StopLoading();
  38. virtual bool Refresh();
  39. virtual void SetVisible(bool state);
  40. virtual bool Show( bool state );
  41. void CreateBrowser( bool AllowJavaScript );
  42. HWND GetHWND() { return m_parent; }
  43. HWND GetIEHWND() { return m_ieHWND;}
  44. HWND GetObjectHWND() { return m_oleObjectHWND;}
  45. vgui::IHTMLEvents *GetEvents() {return m_events;}
  46. //HDC OnPaint(HDC hDC,HBITMAP *bits);
  47. virtual void OnPaint(HDC hDC);
  48. virtual vgui::IImage *GetBitmap() { return m_Bitmap; }
  49. virtual void Obsolete_OnSize(int x,int y, int w,int h);
  50. virtual void ScrollHTML(int x,int y);
  51. virtual void OnMouse(vgui::MouseCode code,MOUSE_STATE s,int x,int y);
  52. // virtual void OnMouse2(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam);
  53. virtual void OnChar(wchar_t unichar);
  54. virtual void OnKeyDown(vgui::KeyCode code);
  55. virtual void AddText(const char *text);
  56. virtual void Clear();
  57. virtual bool OnMouseOver();
  58. void GetSize(int &wide,int &tall) {wide=w ; tall=h;}
  59. virtual void GetHTMLSize(int &wide,int &tall) {wide=html_w ; tall=html_h;}
  60. // events
  61. virtual bool OnStartURL(const char *url, const char *target, bool first);
  62. virtual void OnFinishURL(const char *url);
  63. virtual void OnProgressURL(long current, long maximum);
  64. virtual void OnSetStatusText(const char *text);
  65. virtual void OnUpdate();
  66. virtual void OnLink();
  67. virtual void OffLink();
  68. const char *GetOpenedPage() { return m_currentUrl; }
  69. RECT SetBounds();
  70. int textureID; // used by the engine code
  71. void NewWindow(IDispatch **pIDispatch);
  72. void CalculateHTMLSize( void *pVoid );
  73. HHOOK GetHook() { return m_hHook; }
  74. void *GetIEWndProc() { return (void *)m_hIEWndProc; }
  75. UINT GetMousePos() { return m_iMousePos;}
  76. UINT GetMouseMessage() { return mouse_msg;}
  77. bool IsVisible() { return m_bVisible; }
  78. virtual void Obsolete_OnMouse(vgui::MouseCode code,MOUSE_STATE s,int x,int y) {}
  79. virtual void Obsolete_OnChar(wchar_t unichar) {}
  80. virtual void Obsolete_OnKeyDown(vgui::KeyCode code) {}
  81. private:
  82. // support functions
  83. bool CheckIsLink(IHTMLElement *el, char *type);
  84. char m_currentUrl[512]; // the currently opened URL
  85. bool m_specificallyOpened;
  86. long w,h; // viewport size
  87. long window_x, window_y;
  88. long html_w,html_h; // html page size
  89. long html_x,html_y; // html page offset
  90. // active X container objects
  91. IConnectionPoint * m_connectionPoint;
  92. IWebBrowser2 * m_webBrowser;
  93. IOleObject * m_oleObject;
  94. IOleInPlaceObject * m_oleInPlaceObject;
  95. IViewObject * m_viewObject;
  96. HWND m_parent; // the HWND of the vgui parent
  97. HWND m_oleObjectHWND; // the oleObjects window (which is inside the main window)
  98. HWND m_ieHWND; // the handle to the IE browser itself, which is inside oleObject
  99. vgui::VPANEL m_vcontext; // the vpanel of our frame, used to find out the abs pos of the panel
  100. vgui::IHTMLEvents *m_events; // place to send events to
  101. // state vars for OnPaint()
  102. HDC hdcMem;
  103. HDC lasthDC;
  104. HBITMAP hBitmap;
  105. vgui::MemoryBitmap *m_Bitmap; // the vgui image that the page is rendered into
  106. bool m_cleared,m_newpage; //
  107. bool m_bDirectToHWND;
  108. void *m_fs; // a pointer to the framesite object for this control
  109. DWORD m_adviseCookie; // cookies (magic numbers) used to hook into ActiveX events
  110. DWORD m_HtmlEventsAdviseCookie;
  111. HHOOK m_hHook; // hook for window events
  112. bool m_bHooked; // whether a hook has been installed yet
  113. LPARAM m_iMousePos; // the lParam value for the last mouse movement on the object, used in GetMsgProc()
  114. UINT mouse_msg; // used to enumerate mouse functions to child windows, see EnunChildProc()
  115. bool m_bVisible;
  116. long m_hIEWndProc;
  117. };
  118. #endif // _WIN32
  119. #endif // _HTMLWINDOW_H_