| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_ENGINE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_ENGINE_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_ENGINE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_ENGINE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 } // namespace ui | 33 } // namespace ui |
| 34 | 34 |
| 35 namespace input_method { | 35 namespace input_method { |
| 36 class InputMethodEngineBase; | 36 class InputMethodEngineBase; |
| 37 } | 37 } |
| 38 | 38 |
| 39 namespace chromeos { | 39 namespace chromeos { |
| 40 | 40 |
| 41 class InputMethodEngine : public ::input_method::InputMethodEngineBase { | 41 class InputMethodEngine : public ::input_method::InputMethodEngineBase { |
| 42 public: | 42 public: |
| 43 enum { |
| 44 MENU_ITEM_MODIFIED_LABEL = 0x0001, |
| 45 MENU_ITEM_MODIFIED_STYLE = 0x0002, |
| 46 MENU_ITEM_MODIFIED_VISIBLE = 0x0004, |
| 47 MENU_ITEM_MODIFIED_ENABLED = 0x0008, |
| 48 MENU_ITEM_MODIFIED_CHECKED = 0x0010, |
| 49 MENU_ITEM_MODIFIED_ICON = 0x0020, |
| 50 }; |
| 51 |
| 52 enum MenuItemStyle { |
| 53 MENU_ITEM_STYLE_NONE, |
| 54 MENU_ITEM_STYLE_CHECK, |
| 55 MENU_ITEM_STYLE_RADIO, |
| 56 MENU_ITEM_STYLE_SEPARATOR, |
| 57 }; |
| 58 |
| 59 enum CandidateWindowPosition { |
| 60 WINDOW_POS_CURSOR, |
| 61 WINDOW_POS_COMPOSITTION, |
| 62 }; |
| 63 |
| 64 struct MenuItem { |
| 65 MenuItem(); |
| 66 virtual ~MenuItem(); |
| 67 |
| 68 std::string id; |
| 69 std::string label; |
| 70 MenuItemStyle style; |
| 71 bool visible; |
| 72 bool enabled; |
| 73 bool checked; |
| 74 |
| 75 unsigned int modified; |
| 76 std::vector<MenuItem> children; |
| 77 }; |
| 78 |
| 79 struct UsageEntry { |
| 80 std::string title; |
| 81 std::string body; |
| 82 }; |
| 83 |
| 84 struct Candidate { |
| 85 Candidate(); |
| 86 virtual ~Candidate(); |
| 87 |
| 88 std::string value; |
| 89 int id; |
| 90 std::string label; |
| 91 std::string annotation; |
| 92 UsageEntry usage; |
| 93 std::vector<Candidate> candidates; |
| 94 }; |
| 95 |
| 96 struct CandidateWindowProperty { |
| 97 CandidateWindowProperty(); |
| 98 virtual ~CandidateWindowProperty(); |
| 99 int page_size; |
| 100 bool is_cursor_visible; |
| 101 bool is_vertical; |
| 102 bool show_window_at_composition; |
| 103 |
| 104 // Auxiliary text is typically displayed in the footer of the candidate |
| 105 // window. |
| 106 std::string auxiliary_text; |
| 107 bool is_auxiliary_text_visible; |
| 108 }; |
| 109 |
| 43 InputMethodEngine(); | 110 InputMethodEngine(); |
| 44 | 111 |
| 45 ~InputMethodEngine() override; | 112 ~InputMethodEngine() override; |
| 46 | 113 |
| 47 // IMEEngineHandlerInterface overrides. | 114 // IMEEngineHandlerInterface overrides. |
| 48 bool SendKeyEvents(int context_id, | 115 bool SendKeyEvents(int context_id, |
| 49 const std::vector<KeyboardEvent>& events) override; | 116 const std::vector<KeyboardEvent>& events) override; |
| 50 const CandidateWindowProperty& GetCandidateWindowProperty() const override; | |
| 51 void SetCandidateWindowProperty( | |
| 52 const CandidateWindowProperty& property) override; | |
| 53 bool SetCandidateWindowVisible(bool visible, std::string* error) override; | 117 bool SetCandidateWindowVisible(bool visible, std::string* error) override; |
| 54 bool SetCandidates(int context_id, | |
| 55 const std::vector<Candidate>& candidates, | |
| 56 std::string* error) override; | |
| 57 bool SetCursorPosition(int context_id, | 118 bool SetCursorPosition(int context_id, |
| 58 int candidate_id, | 119 int candidate_id, |
| 59 std::string* error) override; | 120 std::string* error) override; |
| 60 bool SetMenuItems(const std::vector<MenuItem>& items) override; | |
| 61 bool UpdateMenuItems(const std::vector<MenuItem>& items) override; | |
| 62 bool IsActive() const override; | 121 bool IsActive() const override; |
| 63 void Enable(const std::string& component_id) override; | 122 void Enable(const std::string& component_id) override; |
| 64 void PropertyActivate(const std::string& property_name) override; | 123 void PropertyActivate(const std::string& property_name) override; |
| 65 void CandidateClicked(uint32_t index) override; | 124 void CandidateClicked(uint32_t index) override; |
| 66 void HideInputView() override; | 125 void HideInputView() override; |
| 67 | 126 |
| 127 // This function returns the current property of the candidate window. |
| 128 // The caller can use the returned value as the default property and |
| 129 // modify some of specified items. |
| 130 const CandidateWindowProperty& GetCandidateWindowProperty() const; |
| 131 |
| 132 // Change the property of the candidate window and repaint the candidate |
| 133 // window widget. |
| 134 void SetCandidateWindowProperty(const CandidateWindowProperty& property); |
| 135 |
| 136 // Set the list of entries displayed in the candidate window. |
| 137 bool SetCandidates(int context_id, |
| 138 const std::vector<Candidate>& candidates, |
| 139 std::string* error); |
| 140 |
| 141 // Set the list of items that appears in the language menu when this IME is |
| 142 // active. |
| 143 bool SetMenuItems(const std::vector<MenuItem>& items); |
| 144 |
| 145 // Update the state of the menu items. |
| 146 bool UpdateMenuItems(const std::vector<MenuItem>& items); |
| 147 |
| 68 private: | 148 private: |
| 69 // Converts MenuItem to InputMethodMenuItem. | 149 // Converts MenuItem to InputMethodMenuItem. |
| 70 void MenuItemToProperty(const MenuItem& item, | 150 void MenuItemToProperty(const MenuItem& item, |
| 71 ui::ime::InputMethodMenuItem* property); | 151 ui::ime::InputMethodMenuItem* property); |
| 72 | 152 |
| 73 // Enables overriding input view page to Virtual Keyboard window. | 153 // Enables overriding input view page to Virtual Keyboard window. |
| 74 void EnableInputView(); | 154 void EnableInputView(); |
| 75 | 155 |
| 76 // The current candidate window. | 156 // The current candidate window. |
| 77 scoped_ptr<ui::CandidateWindow> candidate_window_; | 157 scoped_ptr<ui::CandidateWindow> candidate_window_; |
| 78 | 158 |
| 79 // The current candidate window property. | 159 // The current candidate window property. |
| 80 CandidateWindowProperty candidate_window_property_; | 160 CandidateWindowProperty candidate_window_property_; |
| 81 | 161 |
| 82 // Indicates whether the candidate window is visible. | 162 // Indicates whether the candidate window is visible. |
| 83 bool window_visible_; | 163 bool window_visible_; |
| 84 | 164 |
| 85 // Mapping of candidate index to candidate id. | 165 // Mapping of candidate index to candidate id. |
| 86 std::vector<int> candidate_ids_; | 166 std::vector<int> candidate_ids_; |
| 87 | 167 |
| 88 // Mapping of candidate id to index. | 168 // Mapping of candidate id to index. |
| 89 std::map<int, int> candidate_indexes_; | 169 std::map<int, int> candidate_indexes_; |
| 90 }; | 170 }; |
| 91 | 171 |
| 92 } // namespace chromeos | 172 } // namespace chromeos |
| 93 | 173 |
| 94 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_ENGINE_H_ | 174 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_ENGINE_H_ |
| OLD | NEW |