Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROMEOS_DBUS_IBUS_IBUS_LOOKUP_TABLE_H_ | |
| 6 #define CHROMEOS_DBUS_IBUS_IBUS_LOOKUP_TABLE_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 #include <vector> | |
| 10 #include "base/basictypes.h" | |
| 11 #include "chromeos/chromeos_export.h" | |
| 12 | |
| 13 namespace dbus { | |
| 14 class MessageWriter; | |
| 15 class MessageReader; | |
| 16 } // namespace dbus | |
| 17 | |
| 18 namespace chromeos { | |
| 19 // TODO(nona): Remove ibus namespace after complete libibus removal. | |
| 20 namespace ibus { | |
| 21 | |
| 22 // The IBusLookupTable is one of IBusObjects. IBusLookupTable contains IBusTexts | |
| 23 // but all of them are used as plain string. The overview of each data | |
| 24 // strucutres is as follows: | |
| 25 // | |
| 26 // DATA STRUCTURE OVERVIEW: | |
| 27 // variant struct { | |
| 28 // string "IBusLookupTable" | |
| 29 // array [ | |
| 30 // ] | |
| 31 // uint32 9 // Page size | |
| 32 // uint32 1 // Cursor position | |
| 33 // boolean true // Cursor visibility. | |
| 34 // boolean true // Round lookup table or not. Not used in Chrome. | |
| 35 // int32 1 // Orientation | |
| 36 // array [ // Array of candidate text. | |
| 37 // variant struct { | |
| 38 // string "IBusText" | |
| 39 // array [] | |
| 40 // string "Candidate Text" | |
| 41 // variant struct { | |
| 42 // string "IBusAttrList" | |
| 43 // array [] | |
| 44 // array [] | |
| 45 // } | |
| 46 // } | |
| 47 // ... more IBusTexts | |
| 48 // ] | |
| 49 // array [ // Array of label text | |
| 50 // variant struct { | |
| 51 // string "IBusText" | |
| 52 // array [] | |
| 53 // string "1" | |
| 54 // variant struct { | |
| 55 // string "IBusAttrList" | |
| 56 // array [] | |
| 57 // array [] | |
| 58 // } | |
| 59 // } | |
| 60 // ... more IBusTexts | |
| 61 // ] | |
| 62 // } | |
| 63 class IBusLookupTable; | |
| 64 | |
| 65 // Pops a IBusLookupTable from |reader|. | |
| 66 // Returns false if an error occures. | |
| 67 bool CHROMEOS_EXPORT PopIBusLookupTable(dbus::MessageReader* reader, | |
| 68 IBusLookupTable* table); | |
| 69 // Appends a IBusLookupTable to |writer|. | |
| 70 void CHROMEOS_EXPORT AppendIBusLookupTable(const IBusLookupTable& table, | |
| 71 dbus::MessageWriter* writer); | |
| 72 | |
| 73 // An representation of IBusLookupTable object which is used in dbus | |
| 74 // communication with ibus-daemon. | |
| 75 class CHROMEOS_EXPORT IBusLookupTable { | |
| 76 public: | |
| 77 enum Orientation { | |
| 78 IBUS_LOOKUP_TABLE_ORIENTATION_HORIZONTAL = 0, | |
| 79 IBUS_LOOKUP_TABLE_ORIENTATION_VERTICAL = 1, | |
| 80 }; | |
| 81 | |
| 82 // Represents a candidate entry. In dbus communication, each | |
| 83 // field is represented as IBusText, but attributes are not used in Chrome. | |
| 84 // So just simple string is sufficient in this case. | |
| 85 struct Entry { | |
| 86 std::string value; | |
| 87 std::string label; | |
| 88 }; | |
| 89 | |
| 90 IBusLookupTable(); | |
| 91 virtual ~IBusLookupTable(); | |
| 92 | |
| 93 // Accessors. | |
|
satorux1
2012/05/21 20:59:35
Please document the members.
Seigo Nonaka
2012/05/21 21:16:47
Done, wrote in member variable filed.
| |
| 94 uint32 page_size() const { | |
| 95 return page_size_; | |
| 96 } | |
| 97 | |
| 98 void set_page_size(uint32 page_size) { | |
| 99 page_size_ = page_size; | |
| 100 } | |
| 101 | |
| 102 uint32 cursor_position() const { | |
| 103 return cursor_position_; | |
| 104 } | |
| 105 | |
| 106 void set_cursor_position(uint32 cursor_position) { | |
| 107 cursor_position_ = cursor_position; | |
| 108 } | |
| 109 | |
| 110 bool is_cursor_visible() const { | |
| 111 return is_cursor_visible_; | |
| 112 } | |
| 113 | |
| 114 void set_is_cursor_visible(bool is_cursor_visible) { | |
| 115 is_cursor_visible_ = is_cursor_visible; | |
| 116 } | |
| 117 | |
| 118 Orientation orientation() const { | |
| 119 return orientation_; | |
| 120 } | |
| 121 | |
| 122 void set_orientation(Orientation orientation) { | |
| 123 orientation_ = orientation; | |
| 124 } | |
| 125 | |
| 126 const std::vector<Entry>& candidates() const { | |
| 127 return candidates_; | |
| 128 } | |
| 129 | |
| 130 std::vector<Entry>* mutable_candidates() { | |
| 131 return &candidates_; | |
| 132 } | |
| 133 | |
| 134 private: | |
| 135 // The number of candidate in one page. | |
| 136 uint32 page_size_; | |
| 137 uint32 cursor_position_; | |
| 138 bool is_cursor_visible_; | |
| 139 Orientation orientation_; | |
| 140 std::vector<Entry> candidates_; | |
| 141 | |
| 142 DISALLOW_COPY_AND_ASSIGN(IBusLookupTable); | |
| 143 }; | |
| 144 | |
| 145 } // namespace ibus | |
| 146 } // namespace chromeos | |
| 147 | |
| 148 #endif // CHROMEOS_DBUS_IBUS_IBUS_LOOKUP_TABLE_H_ | |
| OLD | NEW |