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.

198 lines
7.5 KiB

  1. //========= Copyright 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef IHTML_H
  8. #define IHTML_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include <vgui/vgui.h>
  13. #include <vgui/MouseCode.h>
  14. #include <vgui/KeyCode.h>
  15. #include <vgui/Cursor.h>
  16. #include <vgui/IImage.h>
  17. namespace vgui
  18. {
  19. //-----------------------------------------------------------------------------
  20. // Purpose: basic interface for a HTML window
  21. //-----------------------------------------------------------------------------
  22. class IHTML
  23. {
  24. public:
  25. // open a new page
  26. virtual void OpenURL(const char *)=0;
  27. // stops the existing page from loading
  28. virtual bool StopLoading()=0;
  29. // refreshes the current page
  30. virtual bool Refresh()=0;
  31. // display the control -- deprecated !! Use SetVisible() instead!
  32. virtual bool Show(bool shown)=0;
  33. // return the currently opened page
  34. virtual const char *GetOpenedPage()=0;
  35. // called when the browser needs to be resized
  36. virtual void Obsolete_OnSize(int x,int y, int w,int h)=0;
  37. // returns the width and height (in pixels) of the HTML full page (not just the displayed region)
  38. virtual void GetHTMLSize(int &wide,int &tall) = 0;
  39. // clear the text in an existing control
  40. virtual void Clear()=0;
  41. // add text to the browser control (as a HTML formated string)
  42. virtual void AddText(const char *text)=0;
  43. enum MOUSE_STATE { UP,DOWN,MOVE,DBLCLICK };
  44. // unused functions we keep around so the vtable layout is binary compatible
  45. virtual void Obsolete_OnMouse(MouseCode code,MOUSE_STATE s,int x,int y)=0;
  46. virtual void Obsolete_OnChar(wchar_t unichar)=0;
  47. virtual void Obsolete_OnKeyDown(KeyCode code)=0;
  48. virtual vgui::IImage *GetBitmap()=0;
  49. virtual void SetVisible( bool state ) = 0;
  50. virtual void SetSize( int wide,int tall )=0;
  51. virtual void OnMouse(MouseCode code,MOUSE_STATE s,int x,int y, bool bPopupMenuMenu )=0;
  52. virtual void OnChar(wchar_t unichar, bool bPopupMenu)=0;
  53. virtual void OnKeyDown(KeyCode code, bool bPopupMenu)=0;
  54. virtual void ScrollV( int nPixels ) = 0;
  55. virtual void ScrollH( int nPixels ) = 0;
  56. virtual void OnMouseWheeled( int delta, bool bPopupMenu )= 0;
  57. // called when the browser needs to be resized
  58. virtual void OnKeyUp(KeyCode code, bool bPopupMenu)=0;
  59. // open a URL with the provided POST data (which can be much larger than the max URL of 512 chars)
  60. // NOTE - You CANNOT have get params (i.e a "?" ) in pchURL if pchPostData is set (due to an IE bug)
  61. virtual void PostURL( const char *pchURL, const char *pchPostData ) = 0;
  62. // Run javascript within the browser control
  63. virtual void RunJavascript( const char *pchScript ) = 0;
  64. virtual void SetMousePosition( int x, int y, bool bPopupMenu ) = 0;
  65. virtual void SetUserAgentInfo( const wchar_t *pwchUserAgent ) = 0;
  66. // can't add custom headers to IE
  67. virtual void AddHeader( const char *pchHeader, const char *pchValue ) = 0;
  68. virtual void SetFileDialogChoice( const char *pchFileName ) = 0;
  69. // we are hiding the popup, so make sure webkit knows
  70. virtual void HidePopup() = 0;
  71. virtual void SetHTMLFocus() = 0;
  72. virtual void KillHTMLFocus() = 0;
  73. // ask webkit about the size of any scrollbars it wants to render
  74. virtual void HorizontalScrollBarSize( int &x, int &y, int &wide, int &tall) = 0;
  75. virtual void VerticalScrollBarSize( int &x, int &y, int &wide, int &tall) = 0;
  76. virtual int HorizontalScroll() = 0;
  77. virtual int VerticalScroll() = 0;
  78. virtual int HorizontalScrollMax() =0;
  79. virtual int VerticalScrollMax() =0;
  80. virtual bool IsHorizontalScrollBarVisible() =0;
  81. virtual bool IsVeritcalScrollBarVisible() =0;
  82. virtual void SetHorizontalScroll( int scroll ) =0;
  83. virtual void SetVerticalScroll( int scroll ) =0;
  84. virtual void ViewSource() = 0;
  85. virtual void Copy() = 0;
  86. virtual void Paste() = 0;
  87. // IE specific calls
  88. virtual bool IsIERender() = 0;
  89. virtual void GetIDispatchPtr( void **pIDispatch ) = 0;
  90. virtual void GetHTMLScroll( int &top, int &left ) = 0;
  91. };
  92. //-----------------------------------------------------------------------------
  93. // Purpose: possible load errors when you open a url in the web browser
  94. //-----------------------------------------------------------------------------
  95. enum EWebPageLoadError
  96. {
  97. eLoadErrorNone = 0,
  98. eMimeTypeNotSupported, // probably trying to download an exe or something
  99. eCacheMiss, // Usually caused by navigating to a page with POST data via back or forward buttons
  100. eBadURL, // bad url passed in (invalid hostname, malformed)
  101. eConnectionProblem, // network connectivity problem, server offline or user not on internet
  102. eProxyConnectionProblem, // User is configured to use proxy, but we can't use it
  103. eLoadErrorUnknown, // not a load type we classify right now, check out cef_handler_errorcode_t for the full list we could translate
  104. };
  105. //-----------------------------------------------------------------------------
  106. // Purpose: basic callback interface for a HTML window
  107. //-----------------------------------------------------------------------------
  108. class IHTMLEvents
  109. {
  110. public:
  111. // unused functions we keep around so the vtable layout is binary compatible
  112. virtual bool Obsolete_OnStartURL(const char *url, const char *target, bool first)=0;
  113. virtual void Obsolete_OnFinishURL(const char *url)=0;
  114. virtual void Obsolete_OnProgressURL(long current, long maximum)=0;
  115. virtual void Obsolete_OnSetStatusText(const char *text) =0;
  116. virtual void Obsolete_OnUpdate() =0;
  117. virtual void Obsolete_OnLink()=0;
  118. virtual void Obsolete_OffLink()=0;
  119. // call backs for events
  120. // when the top level browser is changing the page they are looking at (not sub iframes or the like loading)
  121. virtual void OnURLChanged( const char *url, const char *pchPostData, bool bIsRedirect ) = 0;
  122. // the control has finished loading a request, could be a sub request in the page
  123. virtual void OnFinishRequest( const char *url, const char *pageTitle ) = 0;
  124. // the lower html control wants to load a url, do we allow it?
  125. virtual bool OnStartRequestInternal( const char *url, const char *target, const char *pchPostData, bool bIsRedirect ) = 0;
  126. // show a popup menu for this html control
  127. virtual void ShowPopup( int x, int y, int wide, int tall ) = 0;
  128. // hide any popup menu you are showing
  129. virtual void HidePopup() = 0;
  130. // show an external html window at this position and side
  131. virtual bool OnPopupHTMLWindow( const char *pchURL, int x, int y, int wide, int tall ) = 0;
  132. // the browser is telling us the title it would like us to show
  133. virtual void SetHTMLTitle( const char *pchTitle ) = 0;
  134. // the browser is loading a sub url for a page, usually an image or css
  135. virtual void OnLoadingResource( const char *pchURL ) = 0;
  136. // the browser is telling us the user is hovering a url or the like
  137. virtual void OnSetStatusText(const char *text) =0;
  138. // the browser wants the cursor changed please
  139. virtual void OnSetCursor( vgui::CursorCode cursor ) = 0;
  140. // the browser wants to ask the user to select a local file and tell it about it
  141. virtual void OnFileLoadDialog( const char *pchTitle, const char *pchInitialFile ) = 0;
  142. // show and hide tooltip text
  143. virtual void OnShowToolTip( const char *pchText ) = 0;
  144. virtual void OnUpdateToolTip( const char *pchText ) = 0;
  145. virtual void OnHideToolTip() = 0;
  146. // IE only code
  147. virtual bool BOnCreateNewWindow( void **ppDispatch ) = 0;
  148. virtual void OnLink()=0;
  149. virtual void OffLink()=0;
  150. virtual void OnCloseWindow() = 0;
  151. virtual void OnUpdate() =0;
  152. virtual void OnProgressRequest(long current, long maximum)=0;
  153. };
  154. }
  155. #endif // IHTML_H