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

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: Apply comments 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
« no previous file with comments | « chromeos/chromeos.gyp ('k') | chromeos/dbus/ibus/ibus_lookup_table.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 {
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.
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 candidates in one page.
satorux1 2012/05/22 22:17:12 I think we should move comments like this to gette
Seigo Nonaka 2012/05/23 02:40:50 I see. Done. On 2012/05/22 22:17:12, satorux1 wrot
136 uint32 page_size_;
137
138 // The cursor index of the currently selected candidate.
139 uint32 cursor_position_;
140
141 // True if the cusros is visible.
142 bool is_cursor_visible_;
143
144 // Indicates the orientation of lookup table.
145 Orientation orientation_;
146 std::vector<Entry> candidates_;
147
148 DISALLOW_COPY_AND_ASSIGN(IBusLookupTable);
149 };
150
151 } // namespace ibus
152 } // namespace chromeos
153
154 #endif // CHROMEOS_DBUS_IBUS_IBUS_LOOKUP_TABLE_H_
OLDNEW
« no previous file with comments | « chromeos/chromeos.gyp ('k') | chromeos/dbus/ibus/ibus_lookup_table.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698