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

Side by Side Diff: chromeos/ime/candidate_window.h

Issue 24946003: Rename IBusLookupTable to CandidateWindow, and move it to chromeos/ime. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 7 years, 2 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/dbus/ibus/ibus_lookup_table_unittest.cc ('k') | chromeos/ime/candidate_window.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROMEOS_DBUS_IBUS_IBUS_LOOKUP_TABLE_H_ 5 #ifndef CHROMEOS_IME_CANDIDATE_WINDOW_H_
6 #define CHROMEOS_DBUS_IBUS_IBUS_LOOKUP_TABLE_H_ 6 #define CHROMEOS_IME_CANDIDATE_WINDOW_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "chromeos/chromeos_export.h" 12 #include "chromeos/chromeos_export.h"
13 13
14 namespace chromeos { 14 namespace chromeos {
15 namespace input_method {
15 16
16 // The IBusLookupTable is one of IBusObjects. IBusLookupTable contains IBusTexts 17 // CandidateWindow represents the structure of candidates generated from IME.
17 // but all of them are used as plain string. The overview of each data 18 class CHROMEOS_EXPORT CandidateWindow {
18 // structure is as follows:
19 //
20 // DATA STRUCTURE OVERVIEW:
21 // variant struct {
22 // string "IBusLookupTable"
23 // array [
24 // dict_entry (
25 // string "window_show_at_composition"
26 // variant variant boolean false
27 // ]
28 // )
29 // ]
30 // uint32 9 // Page size
31 // uint32 1 // Cursor position
32 // boolean true // Cursor visibility.
33 // boolean true // Round lookup table or not. Not used in Chrome.
34 // int32 1 // Orientation
35 // array [ // Array of candidate text.
36 // variant struct {
37 // string "IBusText"
38 // array []
39 // string "Candidate Text"
40 // variant struct {
41 // string "IBusAttrList"
42 // array []
43 // array []
44 // }
45 // }
46 // ... more IBusTexts
47 // ]
48 // array [ // Array of label text
49 // variant struct {
50 // string "IBusText"
51 // array []
52 // string "1"
53 // variant struct {
54 // string "IBusAttrList"
55 // array []
56 // array []
57 // }
58 // }
59 // ... more IBusTexts
60 // ]
61 // }
62 // TODO(nona): Clean up the structure.(crbug.com/129403)
63
64 // An representation of IBusLookupTable object which is used in dbus
65 // communication with ibus-daemon.
66 class CHROMEOS_EXPORT IBusLookupTable {
67 public: 19 public:
68 enum Orientation { 20 enum Orientation {
69 HORIZONTAL = 0, 21 HORIZONTAL = 0,
70 VERTICAL = 1, 22 VERTICAL = 1,
71 }; 23 };
72 24
73 struct CandidateWindowProperty { 25 struct CandidateWindowProperty {
74 CandidateWindowProperty(); 26 CandidateWindowProperty();
75 virtual ~CandidateWindowProperty(); 27 virtual ~CandidateWindowProperty();
76 int page_size; 28 int page_size;
77 int cursor_position; 29 int cursor_position;
78 bool is_cursor_visible; 30 bool is_cursor_visible;
79 bool is_vertical; 31 bool is_vertical;
80 bool show_window_at_composition; 32 bool show_window_at_composition;
81 }; 33 };
82 34
83 // Represents a candidate entry. In dbus communication, each 35 // Represents a candidate entry.
84 // field is represented as IBusText, but attributes are not used in Chrome.
85 // So just simple string is sufficient in this case.
86 struct Entry { 36 struct Entry {
87 Entry(); 37 Entry();
88 virtual ~Entry(); 38 virtual ~Entry();
89 std::string value; 39 std::string value;
90 std::string label; 40 std::string label;
91 std::string annotation; 41 std::string annotation;
92 std::string description_title; 42 std::string description_title;
93 std::string description_body; 43 std::string description_body;
94 }; 44 };
95 45
96 IBusLookupTable(); 46 CandidateWindow();
97 virtual ~IBusLookupTable(); 47 virtual ~CandidateWindow();
98 48
99 // Returns true if the given |table| is equal to myself. 49 // Returns true if the given |candidate_window| is equal to myself.
100 bool IsEqual(const IBusLookupTable& table) const; 50 bool IsEqual(const CandidateWindow& candidate_window) const;
101 51
102 // Copies |table| to myself. 52 // Copies |candidate_window| to myself.
103 void CopyFrom(const IBusLookupTable& table); 53 void CopyFrom(const CandidateWindow& candidate_window);
104 54
105 const CandidateWindowProperty& GetProperty() const { 55 const CandidateWindowProperty& GetProperty() const {
106 return *property_; 56 return *property_;
107 } 57 }
108 void SetProperty(const CandidateWindowProperty& property) { 58 void SetProperty(const CandidateWindowProperty& property) {
109 *property_ = property; 59 *property_ = property;
110 } 60 }
111 61
112 // Returns the number of candidates in one page. 62 // Returns the number of candidates in one page.
113 uint32 page_size() const { return property_->page_size; } 63 uint32 page_size() const { return property_->page_size; }
114 void set_page_size(uint32 page_size) { property_->page_size = page_size; } 64 void set_page_size(uint32 page_size) { property_->page_size = page_size; }
115 65
116 // Returns the cursor index of the currently selected candidate. 66 // Returns the cursor index of the currently selected candidate.
117 uint32 cursor_position() const { return property_->cursor_position; } 67 uint32 cursor_position() const { return property_->cursor_position; }
118 void set_cursor_position(uint32 cursor_position) { 68 void set_cursor_position(uint32 cursor_position) {
119 property_->cursor_position = cursor_position; 69 property_->cursor_position = cursor_position;
120 } 70 }
121 71
122 // Returns true if the cursor is visible. 72 // Returns true if the cursor is visible.
123 bool is_cursor_visible() const { return property_->is_cursor_visible; } 73 bool is_cursor_visible() const { return property_->is_cursor_visible; }
124 void set_is_cursor_visible(bool is_cursor_visible) { 74 void set_is_cursor_visible(bool is_cursor_visible) {
125 property_->is_cursor_visible = is_cursor_visible; 75 property_->is_cursor_visible = is_cursor_visible;
126 } 76 }
127 77
128 // Returns the orientation of lookup table. 78 // Returns the orientation of the candidate window.
129 Orientation orientation() const { 79 Orientation orientation() const {
130 return property_->is_vertical ? VERTICAL : HORIZONTAL; 80 return property_->is_vertical ? VERTICAL : HORIZONTAL;
131 } 81 }
132 void set_orientation(Orientation orientation) { 82 void set_orientation(Orientation orientation) {
133 property_->is_vertical = (orientation == VERTICAL); 83 property_->is_vertical = (orientation == VERTICAL);
134 } 84 }
135 85
136 const std::vector<Entry>& candidates() const { return candidates_; } 86 const std::vector<Entry>& candidates() const { return candidates_; }
137 std::vector<Entry>* mutable_candidates() { return &candidates_; } 87 std::vector<Entry>* mutable_candidates() { return &candidates_; }
138 88
139 bool show_window_at_composition() const { 89 bool show_window_at_composition() const {
140 return property_->show_window_at_composition; 90 return property_->show_window_at_composition;
141 } 91 }
142 void set_show_window_at_composition(bool show_window_at_composition) { 92 void set_show_window_at_composition(bool show_window_at_composition) {
143 property_->show_window_at_composition = show_window_at_composition; 93 property_->show_window_at_composition = show_window_at_composition;
144 } 94 }
145 95
146 private: 96 private:
147 scoped_ptr<CandidateWindowProperty> property_; 97 scoped_ptr<CandidateWindowProperty> property_;
148 std::vector<Entry> candidates_; 98 std::vector<Entry> candidates_;
149 99
150 DISALLOW_COPY_AND_ASSIGN(IBusLookupTable); 100 DISALLOW_COPY_AND_ASSIGN(CandidateWindow);
151 }; 101 };
152 102
103 } // namespace input_method
153 } // namespace chromeos 104 } // namespace chromeos
154 105
155 #endif // CHROMEOS_DBUS_IBUS_IBUS_LOOKUP_TABLE_H_ 106 #endif // CHROMEOS_IME_CANDIDATE_WINDOW_H_
OLDNEW
« no previous file with comments | « chromeos/dbus/ibus/ibus_lookup_table_unittest.cc ('k') | chromeos/ime/candidate_window.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698