| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROMEOS_IME_CANDIDATE_WINDOW_H_ | |
| 6 #define CHROMEOS_IME_CANDIDATE_WINDOW_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 #include <vector> | |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "chromeos/chromeos_export.h" | |
| 13 | |
| 14 namespace chromeos { | |
| 15 namespace input_method { | |
| 16 | |
| 17 // CandidateWindow represents the structure of candidates generated from IME. | |
| 18 class CHROMEOS_EXPORT CandidateWindow { | |
| 19 public: | |
| 20 enum Orientation { | |
| 21 HORIZONTAL = 0, | |
| 22 VERTICAL = 1, | |
| 23 }; | |
| 24 | |
| 25 struct CandidateWindowProperty { | |
| 26 CandidateWindowProperty(); | |
| 27 virtual ~CandidateWindowProperty(); | |
| 28 int page_size; | |
| 29 int cursor_position; | |
| 30 bool is_cursor_visible; | |
| 31 bool is_vertical; | |
| 32 bool show_window_at_composition; | |
| 33 | |
| 34 // Auxiliary text is typically displayed in the footer of the candidate | |
| 35 // window. | |
| 36 std::string auxiliary_text; | |
| 37 bool is_auxiliary_text_visible; | |
| 38 }; | |
| 39 | |
| 40 // Represents a candidate entry. | |
| 41 struct Entry { | |
| 42 Entry(); | |
| 43 virtual ~Entry(); | |
| 44 std::string value; | |
| 45 std::string label; | |
| 46 std::string annotation; | |
| 47 std::string description_title; | |
| 48 std::string description_body; | |
| 49 }; | |
| 50 | |
| 51 CandidateWindow(); | |
| 52 virtual ~CandidateWindow(); | |
| 53 | |
| 54 // Returns true if the given |candidate_window| is equal to myself. | |
| 55 bool IsEqual(const CandidateWindow& candidate_window) const; | |
| 56 | |
| 57 // Copies |candidate_window| to myself. | |
| 58 void CopyFrom(const CandidateWindow& candidate_window); | |
| 59 | |
| 60 const CandidateWindowProperty& GetProperty() const { | |
| 61 return *property_; | |
| 62 } | |
| 63 void SetProperty(const CandidateWindowProperty& property) { | |
| 64 *property_ = property; | |
| 65 } | |
| 66 | |
| 67 // Returns the number of candidates in one page. | |
| 68 uint32 page_size() const { return property_->page_size; } | |
| 69 void set_page_size(uint32 page_size) { property_->page_size = page_size; } | |
| 70 | |
| 71 // Returns the cursor index of the currently selected candidate. | |
| 72 uint32 cursor_position() const { return property_->cursor_position; } | |
| 73 void set_cursor_position(uint32 cursor_position) { | |
| 74 property_->cursor_position = cursor_position; | |
| 75 } | |
| 76 | |
| 77 // Returns true if the cursor is visible. | |
| 78 bool is_cursor_visible() const { return property_->is_cursor_visible; } | |
| 79 void set_is_cursor_visible(bool is_cursor_visible) { | |
| 80 property_->is_cursor_visible = is_cursor_visible; | |
| 81 } | |
| 82 | |
| 83 // Returns the orientation of the candidate window. | |
| 84 Orientation orientation() const { | |
| 85 return property_->is_vertical ? VERTICAL : HORIZONTAL; | |
| 86 } | |
| 87 void set_orientation(Orientation orientation) { | |
| 88 property_->is_vertical = (orientation == VERTICAL); | |
| 89 } | |
| 90 | |
| 91 // Returns true if the auxiliary text is visible. | |
| 92 bool is_auxiliary_text_visible() const { | |
| 93 return property_->is_auxiliary_text_visible; | |
| 94 } | |
| 95 void set_is_auxiliary_text_visible(bool is_auxiliary_text_visible) const { | |
| 96 property_->is_auxiliary_text_visible = is_auxiliary_text_visible; | |
| 97 } | |
| 98 | |
| 99 // Accessors of auxiliary_text. | |
| 100 const std::string& auxiliary_text() const { | |
| 101 return property_->auxiliary_text; | |
| 102 } | |
| 103 void set_auxiliary_text(const std::string& auxiliary_text) const { | |
| 104 property_->auxiliary_text = auxiliary_text; | |
| 105 } | |
| 106 | |
| 107 const std::vector<Entry>& candidates() const { return candidates_; } | |
| 108 std::vector<Entry>* mutable_candidates() { return &candidates_; } | |
| 109 | |
| 110 bool show_window_at_composition() const { | |
| 111 return property_->show_window_at_composition; | |
| 112 } | |
| 113 void set_show_window_at_composition(bool show_window_at_composition) { | |
| 114 property_->show_window_at_composition = show_window_at_composition; | |
| 115 } | |
| 116 | |
| 117 private: | |
| 118 scoped_ptr<CandidateWindowProperty> property_; | |
| 119 std::vector<Entry> candidates_; | |
| 120 | |
| 121 DISALLOW_COPY_AND_ASSIGN(CandidateWindow); | |
| 122 }; | |
| 123 | |
| 124 } // namespace input_method | |
| 125 } // namespace chromeos | |
| 126 | |
| 127 #endif // CHROMEOS_IME_CANDIDATE_WINDOW_H_ | |
| OLD | NEW |