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 | |
20 // The IBusLookupTable is one of IBusObjects. IBusLookupTable contains IBusTexts | |
21 // but all of them are used as plain string. The overview of each data | |
22 // strucutres is as follows: | |
23 // | |
24 // DATA STRUCTURE OVERVIEW: | |
25 // variant struct { | |
26 // string "IBusLookupTable" | |
27 // array [ | |
28 // ] | |
29 // uint32 9 // Page size | |
30 // uint32 1 // Cursor position | |
31 // boolean true // Cursor visibility. | |
32 // boolean true // Round lookup table or not. Not used in Chrome. | |
33 // int32 1 // Orientation | |
34 // array [ // Array of candidate text. | |
35 // variant struct { | |
36 // string "IBusText" | |
37 // array [] | |
38 // string "青" | |
39 // variant struct { | |
40 // string "IBusAttrList" | |
41 // array [] | |
42 // array [] | |
43 // } | |
44 // } | |
45 // ... more IBusTexts | |
46 // ] | |
47 // array [ // Array of label text | |
48 // variant struct { | |
49 // string "IBusText" | |
50 // array [] | |
51 // string "1" | |
52 // variant struct { | |
53 // string "IBusAttrList" | |
54 // array [] | |
55 // array [] | |
56 // } | |
57 // } | |
58 // ... more IBusTexts | |
59 // ] | |
60 // } | |
61 class IBusLookupTable; | |
62 | |
63 // Pops a IBusLookupTable from |reader|. | |
64 // Returns false if an error occures. | |
65 bool CHROMEOS_EXPORT PopIBusLookupTable(dbus::MessageReader* reader, | |
66 IBusLookupTable* table); | |
67 // Appends a IBusLookupTable to |writer|. | |
68 void CHROMEOS_EXPORT AppendIBusLookupTable(const IBusLookupTable& table, | |
69 dbus::MessageWriter* writer); | |
70 | |
71 // An representation of IBusLookupTable object which is used in dbus | |
72 // communication with ibus-daemon. | |
73 class CHROMEOS_EXPORT IBusLookupTable { | |
74 public: | |
75 enum Orientation { | |
76 IBUS_LOOKUP_TABLE_ORIENTATION_HORIZONTAL = 0, | |
77 IBUS_LOOKUP_TABLE_ORIENTATION_VERTICAL = 1, | |
78 }; | |
79 | |
80 IBusLookupTable(); | |
81 virtual ~IBusLookupTable(); | |
82 | |
83 // Accessors. | |
84 uint32 page_size() const; | |
85 void set_page_size(uint32 page_size); | |
86 | |
87 uint32 cursor_position() const; | |
88 void set_cursor_position(uint32 cursor_position); | |
89 | |
90 bool is_cursor_visible() const; | |
91 void set_is_cursor_visible(bool is_cursor_visible); | |
92 | |
93 Orientation orientation() const; | |
94 void set_orientation(Orientation orientation); | |
95 | |
96 const std::vector<std::string>& candidates() const; | |
97 std::vector<std::string>* mutable_candidates(); | |
98 | |
99 const std::vector<std::string>& labels() const; | |
100 std::vector<std::string>* mutable_labels(); | |
101 | |
102 private: | |
103 // The number of candidate in one page. | |
104 uint32 page_size_; | |
105 uint32 cursor_position_; | |
106 bool is_cursor_visible_; | |
107 Orientation orientation_; | |
108 | |
109 // A vector of candidate string. In dbus communication, this field is | |
110 // represent as IBusText, but attributes are not used in Chrome. So just | |
111 // simple string is enough in this case. | |
112 std::vector<std::string> candidates_; | |
113 | |
114 // A vector of label string. In dbus communication, this field is represent as | |
115 // IBusText, but attributes are not used in Chrome. So just simple string is | |
116 // enough in this case. | |
117 std::vector<std::string> labels_; | |
satorux1
2012/05/11 22:55:29
I thought candidates_ and labels_ should have the
Seigo Nonaka
2012/05/18 17:57:46
Done.
| |
118 | |
119 DISALLOW_COPY_AND_ASSIGN(IBusLookupTable); | |
120 }; | |
121 | |
122 } // namespace chromeos | |
123 | |
124 #endif // CHROMEOS_DBUS_IBUS_IBUS_LOOKUP_TABLE_H_ | |
OLD | NEW |