diff options
author | crupest <crupest@outlook.com> | 2022-02-08 16:53:51 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-02-08 16:53:51 +0800 |
commit | 74bb9cd27242b9320f99ff4d2b50c3051576cc14 (patch) | |
tree | 744bac5799c593d1d6f81e7b09581bea626f2cde /include/cru/platform/gui/InputMethod.h | |
parent | b90c398de829d1ba5329651d75bae82f5e4085fe (diff) | |
download | cru-74bb9cd27242b9320f99ff4d2b50c3051576cc14.tar.gz cru-74bb9cd27242b9320f99ff4d2b50c3051576cc14.tar.bz2 cru-74bb9cd27242b9320f99ff4d2b50c3051576cc14.zip |
...
Diffstat (limited to 'include/cru/platform/gui/InputMethod.h')
-rw-r--r-- | include/cru/platform/gui/InputMethod.h | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/include/cru/platform/gui/InputMethod.h b/include/cru/platform/gui/InputMethod.h new file mode 100644 index 00000000..45e11c06 --- /dev/null +++ b/include/cru/platform/gui/InputMethod.h @@ -0,0 +1,55 @@ +#pragma once +#include "Base.h" + +#include "cru/common/Event.h" + +#include <memory> +#include <vector> + +namespace cru::platform::gui { +struct CompositionClause { + int start; + int end; + bool target; +}; + +using CompositionClauses = std::vector<CompositionClause>; + +struct CompositionText { + String text; + CompositionClauses clauses; + TextRange selection; +}; + +struct IInputMethodContext : virtual IPlatformResource { + // Return true if you should draw composition text manually. Return false if + // system will take care of that for you. + virtual bool ShouldManuallyDrawCompositionText() = 0; + + virtual void EnableIME() = 0; + + virtual void DisableIME() = 0; + + virtual void CompleteComposition() = 0; + + virtual void CancelComposition() = 0; + + virtual CompositionText GetCompositionText() = 0; + + // Set the candidate window lefttop. Relative to window lefttop. Use this + // method to prepare typing. + virtual void SetCandidateWindowPosition(const Point& point) = 0; + + // Triggered when user starts composition. + virtual IEvent<std::nullptr_t>* CompositionStartEvent() = 0; + + // Triggered when user stops composition. + virtual IEvent<std::nullptr_t>* CompositionEndEvent() = 0; + + // Triggered every time composition text changes. + virtual IEvent<std::nullptr_t>* CompositionEvent() = 0; + + virtual IEvent<StringView>* TextEvent() = 0; +}; +} // namespace cru::platform::gui + |