CEFInterfaceTextInputMethodContext.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. // Engine/Source/Runtime/WebBrowser/Private/CEF/CEFTextInputMethodContext.h
  2. #pragma once
  3. #include "CoreMinimal.h"
  4. #if WITH_CEF3 && !PLATFORM_LINUX
  5. #include "Layout/Geometry.h"
  6. #include "Widgets/SWindow.h"
  7. #if PLATFORM_WINDOWS
  8. #include "Windows/WindowsHWrapper.h"
  9. #include "Windows/AllowWindowsPlatformTypes.h"
  10. #include "Windows/AllowWindowsPlatformAtomics.h"
  11. #endif
  12. #pragma push_macro("OVERRIDE")
  13. #undef OVERRIDE // cef headers provide their own OVERRIDE macro
  14. THIRD_PARTY_INCLUDES_START
  15. #if PLATFORM_APPLE
  16. PRAGMA_DISABLE_DEPRECATION_WARNINGS
  17. #endif
  18. #include "include/cef_client.h"
  19. #if PLATFORM_APPLE
  20. PRAGMA_ENABLE_DEPRECATION_WARNINGS
  21. #endif
  22. THIRD_PARTY_INCLUDES_END
  23. #pragma pop_macro("OVERRIDE")
  24. #if PLATFORM_WINDOWS
  25. #include "Windows/HideWindowsPlatformAtomics.h"
  26. #include "Windows/HideWindowsPlatformTypes.h"
  27. #endif
  28. #include "GenericPlatform/ITextInputMethodSystem.h"
  29. #include "Layout/Geometry.h"
  30. class FCEFWebInterfaceBrowserWindow;
  31. class FCEFInterfaceImeHandler;
  32. class SWindow;
  33. class FCEFInterfaceTextInputMethodContext : public ITextInputMethodContext
  34. {
  35. public:
  36. virtual ~FCEFInterfaceTextInputMethodContext() {}
  37. static TSharedRef<FCEFInterfaceTextInputMethodContext> Create(const TSharedRef<FCEFInterfaceImeHandler>& InOwner);
  38. void AbortComposition();
  39. bool UpdateCachedGeometry(const FGeometry& AllottedGeometry);
  40. bool CEFCompositionRangeChanged(const CefRange& SelectionRange, const CefRenderHandler::RectList& CharacterBounds);
  41. private:
  42. void ResetComposition();
  43. public:
  44. // ITextInputMethodContext Interface
  45. virtual bool IsComposing() override;
  46. private:
  47. virtual bool IsReadOnly() override;
  48. virtual uint32 GetTextLength() override;
  49. virtual void GetSelectionRange(uint32& BeginIndex, uint32& Length, ECaretPosition& CaretPosition) override;
  50. virtual void SetSelectionRange(const uint32 BeginIndex, const uint32 Length, const ECaretPosition CaretPosition) override;
  51. virtual void GetTextInRange(const uint32 BeginIndex, const uint32 Length, FString& OutString) override;
  52. virtual void SetTextInRange(const uint32 BeginIndex, const uint32 Length, const FString& InString) override;
  53. virtual int32 GetCharacterIndexFromPoint(const FVector2D& Point) override;
  54. virtual bool GetTextBounds(const uint32 BeginIndex, const uint32 Length, FVector2D& Position, FVector2D& Size) override;
  55. virtual void GetScreenBounds(FVector2D& Position, FVector2D& Size) override;
  56. virtual TSharedPtr<FGenericWindow> GetWindow() override;
  57. virtual void BeginComposition() override;
  58. virtual void UpdateCompositionRange(const int32 InBeginIndex, const uint32 InLength) override;
  59. virtual void EndComposition() override;
  60. private:
  61. FCEFInterfaceTextInputMethodContext(const TSharedRef<FCEFInterfaceImeHandler>& InOwner);
  62. TSharedRef<FCEFInterfaceImeHandler> Owner;
  63. TWeakPtr<SWindow> CachedSlateWindow;
  64. FGeometry CachedGeometry;
  65. bool bIsComposing;
  66. int32 CompositionBeginIndex;
  67. uint32 CompositionLength;
  68. uint32 SelectionRangeBeginIndex;
  69. uint32 SelectionRangeLength;
  70. ECaretPosition SelectionCaretPosition;
  71. std::vector<CefRect> CefCompositionBounds;
  72. FString CompositionString;
  73. };
  74. #endif