aboutsummaryrefslogtreecommitdiff
path: root/src/platform/gui/osx/InputMethodPrivate.h
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2022-05-15 14:08:06 +0800
committercrupest <crupest@outlook.com>2022-05-15 14:08:06 +0800
commit8ad2966933957ac5d6ff8dcd5e732736fd5e4dc6 (patch)
tree77e41cc14264060517c0f7ed95837012afb8342e /src/platform/gui/osx/InputMethodPrivate.h
parent9e0c9d3499bc50c3534b4dc500d8b5d0b5f22752 (diff)
downloadcru-8ad2966933957ac5d6ff8dcd5e732736fd5e4dc6.tar.gz
cru-8ad2966933957ac5d6ff8dcd5e732736fd5e4dc6.tar.bz2
cru-8ad2966933957ac5d6ff8dcd5e732736fd5e4dc6.zip
...
Diffstat (limited to 'src/platform/gui/osx/InputMethodPrivate.h')
-rw-r--r--src/platform/gui/osx/InputMethodPrivate.h64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/platform/gui/osx/InputMethodPrivate.h b/src/platform/gui/osx/InputMethodPrivate.h
new file mode 100644
index 00000000..ac2d1bf4
--- /dev/null
+++ b/src/platform/gui/osx/InputMethodPrivate.h
@@ -0,0 +1,64 @@
+#pragma once
+#include "cru/platform/gui/osx/InputMethod.h"
+
+#include <AppKit/AppKit.h>
+
+namespace cru::platform::gui::osx {
+namespace details {
+class OsxInputMethodContextPrivate {
+ friend OsxInputMethodContext;
+
+ public:
+ OsxInputMethodContextPrivate(OsxInputMethodContext* input_method_context,
+ OsxWindow* window);
+
+ CRU_DELETE_COPY(OsxInputMethodContextPrivate)
+ CRU_DELETE_MOVE(OsxInputMethodContextPrivate)
+
+ ~OsxInputMethodContextPrivate();
+
+ void SetCompositionText(CompositionText composition_text) {
+ composition_text_ = std::move(composition_text);
+ }
+
+ void RaiseCompositionStartEvent();
+ void RaiseCompositionEndEvent();
+ void RaiseCompositionEvent();
+ void RaiseTextEvent(StringView text);
+
+ Point GetCandidateWindowPosition() const { return candidate_window_point_; }
+ void SetCandidateWindowPosition(const Point& p) {
+ candidate_window_point_ = p;
+ }
+
+ Range GetSelectionRange() const { return selection_range_; }
+ void SetSelectionRange(Range selection_range) {
+ selection_range_ = selection_range;
+ }
+
+ void PerformSel(SEL sel);
+
+ void Activate();
+ void Deactivate();
+
+ private:
+ OsxWindow* window_;
+
+ CompositionText composition_text_;
+
+ Range selection_range_;
+
+ OsxInputMethodContext* input_method_context_;
+
+ // On Osx, this is the text lefttop point on screen.
+ Point candidate_window_point_;
+
+ Event<std::nullptr_t> composition_start_event_;
+ Event<std::nullptr_t> composition_event_;
+ Event<std::nullptr_t> composition_end_event_;
+ Event<StringView> text_event_;
+
+ bool is_enabled_ = false;
+};
+} // namespace details
+} // namespace cru::platform::gui::osx