WebClient.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #pragma once
  2. #include <Atomic/Container/List.h>
  3. #include <Atomic/Core/Object.h>
  4. #include "WebRenderHandler.h"
  5. class CefClient;
  6. namespace Atomic
  7. {
  8. class WebClientPrivate;
  9. class WebMessageHandler;
  10. class ATOMIC_API WebClient : public Object
  11. {
  12. friend class WebBrowserHost;
  13. friend class WebClientPrivate;
  14. OBJECT(WebClient)
  15. public:
  16. /// Construct.
  17. WebClient(Context* context);
  18. /// Destruct.
  19. virtual ~WebClient();
  20. /// call once initialized with handlers
  21. bool CreateBrowser(const String& initialURL, int width, int height);
  22. void SetSize(int width, int height);
  23. void SetWebRenderHandler(WebRenderHandler* handler);
  24. void SendMouseClickEvent(int x, int y, unsigned button, bool mouseUp, unsigned modifier) const;
  25. void SendMousePressEvent(int x, int y, unsigned button = 0, unsigned modifier = 0) const;
  26. void SendMouseMoveEvent(int x, int y, unsigned modifier, bool mouseLeave = false) const;
  27. void SendMouseWheelEvent(int x, int y, unsigned modifier, int deltaX, int deltaY) const;
  28. void SendFocusEvent(bool focus = true);
  29. void SendTextInputEvent(const StringHash eventType, VariantMap& eventData);
  30. void SendKeyEvent(const StringHash eventType, VariantMap& eventData);
  31. void ShortcutCut();
  32. void ShortcutCopy();
  33. void ShortcutPaste();
  34. void ShortcutSelectAll();
  35. void ShortcutUndo();
  36. void ShortcutRedo();
  37. void ShortcutDelete();
  38. void AddMessageHandler(WebMessageHandler* handler, bool first = false);
  39. void RemoveMessageHandler(WebMessageHandler* handler);
  40. void ExecuteJavaScript(const String& script);
  41. // Navigation
  42. bool IsLoading();
  43. /// Load the specified url into the main frame of the browser
  44. void LoadURL(const String& url);
  45. void GoBack();
  46. void GoForward();
  47. void Reload();
  48. CefClient* GetCefClient();
  49. private:
  50. void WasResized();
  51. SharedPtr<WebRenderHandler> renderHandler_;
  52. List<SharedPtr<WebMessageHandler>> messageHandlers_;
  53. WebClientPrivate* d_;
  54. };
  55. }