Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(295)

Side by Side Diff: chromeos/dbus/ibus/ibus_lookup_table.h

Issue 10392039: Implement IBusLookupTable. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Introduce Entry structure. Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 {
satorux1 2012/05/18 18:27:22 shoudn't we put this in 'ibus' namespace for consi
Seigo Nonaka 2012/05/18 19:53:16 Yes! thanks.
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 "青"
satorux1 2012/05/18 18:27:22 having non-ASCII character is dangerous. please ma
Seigo Nonaka 2012/05/18 19:53:16 Done.
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 // Corresponding to each one candidate entry. In dbus communication, each
satorux1 2012/05/18 18:27:22 Corresponding to each one candidate entry. Repres
Seigo Nonaka 2012/05/18 19:53:16 Done.
81 // field is represented as IBusText, but attributes are not used in Chrome.
82 // So just simple string is enough in this case.
satorux1 2012/05/18 18:27:22 enough -> sufficient?
Seigo Nonaka 2012/05/18 19:53:16 Done.
83 struct Entry {
84 std::string value;
85 std::string label;
86 };
87
88 IBusLookupTable();
89 virtual ~IBusLookupTable();
90
91 // Accessors.
92 uint32 page_size() const {
93 return page_size_;
94 }
95
96 void set_page_size(uint32 page_size) {
97 page_size_ = page_size;
98 }
99
100 uint32 cursor_position() const {
101 return cursor_position_;
102 }
103
104 void set_cursor_position(uint32 cursor_position) {
105 cursor_position_ = cursor_position;
106 }
107
108 bool is_cursor_visible() const {
109 return is_cursor_visible_;
110 }
111
112 void set_is_cursor_visible(bool is_cursor_visible) {
113 is_cursor_visible_ = is_cursor_visible;
114 }
115
116 Orientation orientation() const {
117 return orientation_;
118 }
119
120 void set_orientation(Orientation orientation) {
121 orientation_ = orientation;
122 }
123
124 const std::vector<Entry>& candidates() const {
125 return candidates_;
126 }
127
128 std::vector<Entry>* mutable_candidates() {
129 return &candidates_;
130 }
131
132 private:
133 // The number of candidate in one page.
134 uint32 page_size_;
135 uint32 cursor_position_;
136 bool is_cursor_visible_;
137 Orientation orientation_;
138
139 // A vector of candidate entries.
satorux1 2012/05/18 18:27:22 don't need this comment.
Seigo Nonaka 2012/05/18 19:53:16 Done.
140 std::vector<Entry> candidates_;
141
142 DISALLOW_COPY_AND_ASSIGN(IBusLookupTable);
143 };
144
145 } // namespace chromeos
146
147 #endif // CHROMEOS_DBUS_IBUS_IBUS_LOOKUP_TABLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698