| 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 // The header files provides APIs for monitoring and controlling input | 5 // The header files provides APIs for monitoring and controlling input |
| 6 // method UI status. The APIs encapsulate the APIs of IBus, the underlying | 6 // method UI status. The APIs encapsulate the APIs of IBus, the underlying |
| 7 // input method framework. | 7 // input method framework. |
| 8 // TODO(nona): Remove InputMethodLookupTable and IBusUiController. | 8 // TODO(nona): Remove IBusUiController. |
| 9 | 9 |
| 10 #ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_IBUS_UI_CONTROLLER_H_ | 10 #ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_IBUS_UI_CONTROLLER_H_ |
| 11 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_IBUS_UI_CONTROLLER_H_ | 11 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_IBUS_UI_CONTROLLER_H_ |
| 12 | 12 |
| 13 #include <string> | 13 #include <string> |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 #include "base/basictypes.h" | 16 #include "base/basictypes.h" |
| 17 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
| 18 #include "chromeos/dbus/ibus/ibus_panel_service.h" | 18 #include "chromeos/dbus/ibus/ibus_panel_service.h" |
| 19 | 19 |
| 20 namespace gfx { | 20 namespace gfx { |
| 21 class Rect; | 21 class Rect; |
| 22 } // namespace gfx | 22 } // namespace gfx |
| 23 | 23 |
| 24 namespace chromeos { | 24 namespace chromeos { |
| 25 namespace input_method { | 25 namespace input_method { |
| 26 | 26 |
| 27 // A key for attaching the |ibus_service_panel_| object to |ibus_|. | 27 // A key for attaching the |ibus_service_panel_| object to |ibus_|. |
| 28 const char kPanelObjectKey[] = "panel-object"; | 28 const char kPanelObjectKey[] = "panel-object"; |
| 29 | 29 |
| 30 class InputMethodDescriptor; | 30 class InputMethodDescriptor; |
| 31 typedef std::vector<InputMethodDescriptor> InputMethodDescriptors; | 31 typedef std::vector<InputMethodDescriptor> InputMethodDescriptors; |
| 32 | 32 |
| 33 // The struct represents the input method lookup table (list of candidates). | |
| 34 // Used for InputMethodUpdateLookupTableMonitorFunction. | |
| 35 struct InputMethodLookupTable { | |
| 36 enum Orientation { | |
| 37 kVertical, | |
| 38 kHorizontal, | |
| 39 }; | |
| 40 | |
| 41 struct Description { | |
| 42 std::string title; // Description title string in UTF-8. | |
| 43 std::string body; // Description body string in UTF-8. | |
| 44 }; | |
| 45 | |
| 46 InputMethodLookupTable(); | |
| 47 | |
| 48 ~InputMethodLookupTable(); | |
| 49 | |
| 50 // Debug print function. | |
| 51 std::string ToString() const; | |
| 52 | |
| 53 // True if the lookup table is visible. | |
| 54 bool visible; | |
| 55 | |
| 56 // Zero-origin index of the current cursor position in the all | |
| 57 // candidates. If the cursor is pointing to the third candidate in the | |
| 58 // second page when the page size is 10, the value will be 12 as it's | |
| 59 // 13th candidate. | |
| 60 int cursor_absolute_index; | |
| 61 | |
| 62 // Page size is the max number of candidates shown in a page. Usually | |
| 63 // it's about 10, depending on the backend conversion engine. | |
| 64 int page_size; | |
| 65 | |
| 66 // True if the candidate window should be shown under the first character of | |
| 67 // composition string. | |
| 68 bool show_at_composition_head; | |
| 69 | |
| 70 // Candidate strings in UTF-8. | |
| 71 std::vector<std::string> candidates; | |
| 72 | |
| 73 // The orientation of the candidates in the candidate window. | |
| 74 Orientation orientation; | |
| 75 | |
| 76 // Label strings in UTF-8 (ex. "1", "2", "3", ...). | |
| 77 std::vector<std::string> labels; | |
| 78 | |
| 79 // Annotation strings in UTF-8 (ex. "Hankaku Katakana"). | |
| 80 std::vector<std::string> annotations; | |
| 81 | |
| 82 // Description entries. This text is shown in Infolist window. | |
| 83 std::vector<Description> descriptions; | |
| 84 }; | |
| 85 | |
| 86 // IBusUiController is used to interact with the IBus daemon. | 33 // IBusUiController is used to interact with the IBus daemon. |
| 87 class IBusUiController : public ibus::IBusPanelCandidateWindowHandlerInterface { | 34 class IBusUiController : public ibus::IBusPanelCandidateWindowHandlerInterface { |
| 88 public: | 35 public: |
| 89 class Observer { | 36 class Observer { |
| 90 public: | 37 public: |
| 91 // Called when the auxiliary text becomes hidden. | 38 // Called when the auxiliary text becomes hidden. |
| 92 virtual void OnHideAuxiliaryText() = 0; | 39 virtual void OnHideAuxiliaryText() = 0; |
| 93 | 40 |
| 94 // Called when the lookup table becomes hidden. | 41 // Called when the lookup table becomes hidden. |
| 95 virtual void OnHideLookupTable() = 0; | 42 virtual void OnHideLookupTable() = 0; |
| 96 | 43 |
| 97 // Called when the preedit text becomes hidden. | 44 // Called when the preedit text becomes hidden. |
| 98 virtual void OnHidePreeditText() = 0; | 45 virtual void OnHidePreeditText() = 0; |
| 99 | 46 |
| 100 // Called when the cursor location is set. | 47 // Called when the cursor location is set. |
| 101 virtual void OnSetCursorLocation(const gfx::Rect& cusor_location, | 48 virtual void OnSetCursorLocation(const gfx::Rect& cusor_location, |
| 102 const gfx::Rect& composition_head) = 0; | 49 const gfx::Rect& composition_head) = 0; |
| 103 | 50 |
| 104 // Called when the auxiliary text is updated. | 51 // Called when the auxiliary text is updated. |
| 105 virtual void OnUpdateAuxiliaryText(const std::string& text, | 52 virtual void OnUpdateAuxiliaryText(const std::string& text, |
| 106 bool visible) = 0; | 53 bool visible) = 0; |
| 107 | 54 |
| 108 // Called when the lookup table is updated. | 55 // Called when the lookup table is updated. |
| 109 virtual void OnUpdateLookupTable(const InputMethodLookupTable& table) = 0; | 56 virtual void OnUpdateLookupTable(const ibus::IBusLookupTable& table, |
| 57 bool visible) = 0; |
| 110 | 58 |
| 111 // Called when the preedit text is updated. | 59 // Called when the preedit text is updated. |
| 112 virtual void OnUpdatePreeditText(const std::string& utf8_text, | 60 virtual void OnUpdatePreeditText(const std::string& utf8_text, |
| 113 unsigned int cursor, bool visible) = 0; | 61 unsigned int cursor, bool visible) = 0; |
| 114 }; | 62 }; |
| 115 | 63 |
| 116 IBusUiController(); | 64 IBusUiController(); |
| 117 virtual ~IBusUiController(); | 65 virtual ~IBusUiController(); |
| 118 | 66 |
| 119 // Creates an instance of the class. The constructor is unused. | 67 // Creates an instance of the class. The constructor is unused. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 | 119 |
| 172 ObserverList<Observer> observers_; | 120 ObserverList<Observer> observers_; |
| 173 | 121 |
| 174 DISALLOW_COPY_AND_ASSIGN(IBusUiController); | 122 DISALLOW_COPY_AND_ASSIGN(IBusUiController); |
| 175 }; | 123 }; |
| 176 | 124 |
| 177 } // namespace input_method | 125 } // namespace input_method |
| 178 } // namespace chromeos | 126 } // namespace chromeos |
| 179 | 127 |
| 180 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_IBUS_UI_CONTROLLER_H_ | 128 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_IBUS_UI_CONTROLLER_H_ |
| OLD | NEW |