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.
5 #ifndef CHROMEOS_DBUS_IBUS_IBUS_LOOKUP_TABLE_H_
6 #define CHROMEOS_DBUS_IBUS_IBUS_LOOKUP_TABLE_H_
10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "chromeos/chromeos_export.h"
21 // The IBusLookupTable is one of IBusObjects. IBusLookupTable contains IBusTexts
22 // but all of them are used as plain string. The overview of each data
23 // structure is as follows:
25 // DATA STRUCTURE OVERVIEW:
27 // string "IBusLookupTable"
30 // string "window_show_at_composition"
31 // variant variant boolean false
35 // uint32 9 // Page size
36 // uint32 1 // Cursor position
37 // boolean true // Cursor visibility.
38 // boolean true // Round lookup table or not. Not used in Chrome.
39 // int32 1 // Orientation
40 // array [ // Array of candidate text.
44 // string "Candidate Text"
46 // string "IBusAttrList"
53 // array [ // Array of label text
59 // string "IBusAttrList"
67 // TODO(nona): Clean up the structure.(crbug.com/129403)
68 class IBusLookupTable
;
70 // Pops a IBusLookupTable from |reader|.
71 // Returns false if an error occurs.
72 bool CHROMEOS_EXPORT
PopIBusLookupTable(dbus::MessageReader
* reader
,
73 IBusLookupTable
* table
);
74 // Appends a IBusLookupTable to |writer| except mozc_candidates_ in |table|.
75 void CHROMEOS_EXPORT
AppendIBusLookupTable(const IBusLookupTable
& table
,
76 dbus::MessageWriter
* writer
);
78 // An representation of IBusLookupTable object which is used in dbus
79 // communication with ibus-daemon.
80 class CHROMEOS_EXPORT IBusLookupTable
{
87 // Represents a candidate entry. In dbus communication, each
88 // field is represented as IBusText, but attributes are not used in Chrome.
89 // So just simple string is sufficient in this case.
95 std::string annotation
;
96 std::string description_title
;
97 std::string description_body
;
101 virtual ~IBusLookupTable();
103 // Returns true if the given |table| is equal to myself.
104 bool IsEqual(const IBusLookupTable
& table
) const;
106 // Copies |table| to myself.
107 void CopyFrom(const IBusLookupTable
& table
);
109 // Returns the number of candidates in one page.
110 uint32
page_size() const { return page_size_
; }
111 void set_page_size(uint32 page_size
) { page_size_
= page_size
; }
113 // Returns the cursor index of the currently selected candidate.
114 uint32
cursor_position() const { return cursor_position_
; }
115 void set_cursor_position(uint32 cursor_position
) {
116 cursor_position_
= cursor_position
;
119 // Returns true if the cursor is visible.
120 bool is_cursor_visible() const { return is_cursor_visible_
; }
121 void set_is_cursor_visible(bool is_cursor_visible
) {
122 is_cursor_visible_
= is_cursor_visible
;
125 // Returns the orientation of lookup table.
126 Orientation
orientation() const { return orientation_
; }
127 void set_orientation(Orientation orientation
) {
128 orientation_
= orientation
;
131 const std::vector
<Entry
>& candidates() const { return candidates_
; }
132 std::vector
<Entry
>* mutable_candidates() { return &candidates_
; }
134 bool show_window_at_composition() const {
135 return show_window_at_composition_
;
137 void set_show_window_at_composition(bool show_window_at_composition
) {
138 show_window_at_composition_
= show_window_at_composition
;
143 uint32 cursor_position_
;
144 bool is_cursor_visible_
;
145 Orientation orientation_
;
146 std::vector
<Entry
> candidates_
;
147 bool show_window_at_composition_
;
149 DISALLOW_COPY_AND_ASSIGN(IBusLookupTable
);
152 } // namespace chromeos
154 #endif // CHROMEOS_DBUS_IBUS_IBUS_LOOKUP_TABLE_H_