Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / ui / base / ime / candidate_window.h
blobf8c967e6d69bbd92e41a53e0ee441ed490565632
1 // Copyright 2014 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 UI_BASE_IME_CANDIDATE_WINDOW_H_
6 #define UI_BASE_IME_CANDIDATE_WINDOW_H_
8 #include <string>
9 #include <vector>
10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "ui/base/ime/infolist_entry.h"
13 #include "ui/base/ime/ui_base_ime_export.h"
15 namespace ui {
17 // CandidateWindow represents the structure of candidates generated from IME.
18 class UI_BASE_IME_EXPORT CandidateWindow {
19 public:
20 enum Orientation {
21 HORIZONTAL = 0,
22 VERTICAL = 1,
25 struct UI_BASE_IME_EXPORT CandidateWindowProperty {
26 CandidateWindowProperty();
27 virtual ~CandidateWindowProperty();
28 int page_size;
29 int cursor_position;
30 bool is_cursor_visible;
31 bool is_vertical;
32 bool show_window_at_composition;
34 // Auxiliary text is typically displayed in the footer of the candidate
35 // window.
36 std::string auxiliary_text;
37 bool is_auxiliary_text_visible;
40 // Represents a candidate entry.
41 struct UI_BASE_IME_EXPORT Entry {
42 Entry();
43 virtual ~Entry();
44 base::string16 value;
45 base::string16 label;
46 base::string16 annotation;
47 base::string16 description_title;
48 base::string16 description_body;
51 CandidateWindow();
52 virtual ~CandidateWindow();
54 // Returns true if the given |candidate_window| is equal to myself.
55 bool IsEqual(const CandidateWindow& candidate_window) const;
57 // Copies |candidate_window| to myself.
58 void CopyFrom(const CandidateWindow& candidate_window);
60 const CandidateWindowProperty& GetProperty() const {
61 return *property_;
63 void SetProperty(const CandidateWindowProperty& property) {
64 *property_ = property;
67 // Gets the infolist entry models. Sets |has_highlighted| to true if |entries|
68 // contains highlighted entry.
69 void GetInfolistEntries(std::vector<InfolistEntry>* entries,
70 bool* has_highlighted) const;
72 // Returns the number of candidates in one page.
73 uint32 page_size() const { return property_->page_size; }
74 void set_page_size(uint32 page_size) { property_->page_size = page_size; }
76 // Returns the cursor index of the currently selected candidate.
77 uint32 cursor_position() const { return property_->cursor_position; }
78 void set_cursor_position(uint32 cursor_position) {
79 property_->cursor_position = cursor_position;
82 // Returns true if the cursor is visible.
83 bool is_cursor_visible() const { return property_->is_cursor_visible; }
84 void set_is_cursor_visible(bool is_cursor_visible) {
85 property_->is_cursor_visible = is_cursor_visible;
88 // Returns the orientation of the candidate window.
89 Orientation orientation() const {
90 return property_->is_vertical ? VERTICAL : HORIZONTAL;
92 void set_orientation(Orientation orientation) {
93 property_->is_vertical = (orientation == VERTICAL);
96 // Returns true if the auxiliary text is visible.
97 bool is_auxiliary_text_visible() const {
98 return property_->is_auxiliary_text_visible;
100 void set_is_auxiliary_text_visible(bool is_auxiliary_text_visible) const {
101 property_->is_auxiliary_text_visible = is_auxiliary_text_visible;
104 // Accessors of auxiliary_text.
105 const std::string& auxiliary_text() const {
106 return property_->auxiliary_text;
108 void set_auxiliary_text(const std::string& auxiliary_text) const {
109 property_->auxiliary_text = auxiliary_text;
112 const std::vector<Entry>& candidates() const { return candidates_; }
113 std::vector<Entry>* mutable_candidates() { return &candidates_; }
115 bool show_window_at_composition() const {
116 return property_->show_window_at_composition;
118 void set_show_window_at_composition(bool show_window_at_composition) {
119 property_->show_window_at_composition = show_window_at_composition;
122 private:
123 scoped_ptr<CandidateWindowProperty> property_;
124 std::vector<Entry> candidates_;
126 DISALLOW_COPY_AND_ASSIGN(CandidateWindow);
129 } // namespace ui
131 #endif // UI_BASE_IME_CANDIDATE_WINDOW_H_