OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_BASE_IME_WIN_TSF_EVENT_ROUTER_H_ | 5 #ifndef UI_BASE_IME_WIN_TSF_EVENT_ROUTER_H_ |
6 #define UI_BASE_IME_WIN_TSF_EVENT_ROUTER_H_ | 6 #define UI_BASE_IME_WIN_TSF_EVENT_ROUTER_H_ |
7 | 7 |
8 #include <atlbase.h> | 8 #include <atlbase.h> |
9 #include <atlcom.h> | 9 #include <atlcom.h> |
10 #include <msctf.h> | 10 #include <msctf.h> |
11 | 11 |
12 #include <set> | 12 #include <set> |
13 | 13 |
14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
15 #include "base/callback.h" | 15 #include "base/callback.h" |
16 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
17 #include "ui/base/ime/text_input_type.h" | 17 #include "ui/base/ime/text_input_type.h" |
18 #include "ui/base/range/range.h" | |
18 #include "ui/base/ui_export.h" | 19 #include "ui/base/ui_export.h" |
19 | 20 |
20 struct ITfDocumentMgr; | 21 struct ITfDocumentMgr; |
21 | 22 |
22 namespace ui { | 23 namespace ui { |
23 | 24 |
24 class TsfEventRouterObserver { | 25 class TsfEventRouterObserver { |
25 public: | 26 public: |
26 TsfEventRouterObserver() {} | 27 TsfEventRouterObserver() {} |
27 | 28 |
28 // Called when the text contents are updated. | 29 // Called when the text contents are updated. If there is no composition, |
29 virtual void OnTextUpdated() = 0; | 30 // ui::Range::InvalidRange is passed to |composition_range|. |
31 virtual void OnTextUpdated(const ui::Range& composition_range) = 0; | |
30 | 32 |
31 // Called when the number of currently opened candidate windows changes. | 33 // Called when the number of currently opened candidate windows changes. |
32 virtual void OnCandidateWindowCountChanged(size_t window_count) = 0; | 34 virtual void OnCandidateWindowCountChanged(size_t window_count) = 0; |
33 | 35 |
36 // Called when a composition is started. | |
Peter Kasting
2012/10/27 19:00:46
Nit: I suggest ordering these (here and everywhere
Seigo Nonaka
2012/10/27 22:20:18
Sure, done.
| |
37 virtual void OnTsfStartComposition() = 0; | |
38 | |
39 // Called when a composition is terminated. | |
40 virtual void OnTsfEndComposition() = 0; | |
41 | |
34 protected: | 42 protected: |
35 virtual ~TsfEventRouterObserver() {} | 43 virtual ~TsfEventRouterObserver() {} |
36 | 44 |
37 private: | 45 private: |
38 DISALLOW_COPY_AND_ASSIGN(TsfEventRouterObserver); | 46 DISALLOW_COPY_AND_ASSIGN(TsfEventRouterObserver); |
39 }; | 47 }; |
40 | 48 |
41 // This class monitores TSF related events and forwards them to given | 49 // This class monitores TSF related events and forwards them to given |
42 // |observer|. | 50 // |observer|. |
43 class UI_EXPORT TsfEventRouter { | 51 class UI_EXPORT TsfEventRouter { |
44 public: | 52 public: |
45 // Do not pass NULL to |observer|. | 53 // Do not pass NULL to |observer|. |
46 explicit TsfEventRouter(TsfEventRouterObserver* observer); | 54 explicit TsfEventRouter(TsfEventRouterObserver* observer); |
47 virtual ~TsfEventRouter(); | 55 virtual ~TsfEventRouter(); |
48 | 56 |
49 // Sets |thread_manager| to be monitored. |thread_manager| can be NULL. | 57 // Sets |thread_manager| to be monitored. |thread_manager| can be NULL. |
50 void SetManager(ITfThreadMgr* thread_manager); | 58 void SetManager(ITfThreadMgr* thread_manager); |
51 | 59 |
52 // Returns true if the IME is composing text. | 60 // Returns true if the IME is composing text. |
53 bool IsImeComposing(); | 61 bool IsImeComposing(); |
54 | 62 |
55 // Callbacks from the TsfEventRouterDelegate: | 63 // Callbacks from the TsfEventRouterDelegate: |
56 void OnTextUpdated(); | 64 void OnTextUpdated(const ui::Range& composition_range); |
57 void OnCandidateWindowCountChanged(size_t window_count); | 65 void OnCandidateWindowCountChanged(size_t window_count); |
66 void OnTsfStartComposition(); | |
67 void OnTsfEndComposition(); | |
58 | 68 |
59 private: | 69 private: |
60 class TsfEventRouterDelegate; | 70 class TsfEventRouterDelegate; |
61 | 71 |
62 CComPtr<TsfEventRouterDelegate> delegate_; | 72 CComPtr<TsfEventRouterDelegate> delegate_; |
63 | 73 |
64 TsfEventRouterObserver* observer_; | 74 TsfEventRouterObserver* observer_; |
65 | 75 |
66 DISALLOW_COPY_AND_ASSIGN(TsfEventRouter); | 76 DISALLOW_COPY_AND_ASSIGN(TsfEventRouter); |
67 }; | 77 }; |
68 | 78 |
69 } // namespace ui | 79 } // namespace ui |
70 | 80 |
71 #endif // UI_BASE_IME_WIN_TSF_EVENT_ROUTER_H_ | 81 #endif // UI_BASE_IME_WIN_TSF_EVENT_ROUTER_H_ |
OLD | NEW |