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 CHROME_BROWSER_CHROMEOS_INPUT_METHOD_CANDIDATE_VIEW_H_
6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_CANDIDATE_VIEW_H_
8 #include "base/gtest_prod_util.h"
9 #include "chrome/browser/chromeos/input_method/ibus_ui_controller.h"
10 #include "ui/views/controls/label.h"
11 #include "ui/views/view.h"
14 namespace input_method
{
16 class CandidateWindowView
;
18 // CandidateView renderes a row of a candidate.
19 class CandidateView
: public views::View
{
21 CandidateView(CandidateWindowView
* parent_candidate_window
,
23 InputMethodLookupTable::Orientation orientation
);
24 virtual ~CandidateView() {}
25 // Initializes the candidate view with the given column widths.
26 // A width of 0 means that the column is resizable.
27 void Init(int shortcut_column_width
,
28 int candidate_column_width
,
29 int annotation_column_width
,
32 // Sets candidate text to the given text.
33 void SetCandidateText(const string16
& text
);
35 // Sets shortcut text to the given text.
36 void SetShortcutText(const string16
& text
);
38 // Sets annotation text to the given text.
39 void SetAnnotationText(const string16
& text
);
41 // Sets infolist icon.
42 void SetInfolistIcon(bool enable
);
44 // Selects the candidate row. Changes the appearance to make it look
45 // like a selected candidate.
48 // Unselects the candidate row. Changes the appearance to make it look
49 // like an unselected candidate.
52 // Enables or disables the candidate row based on |enabled|. Changes the
53 // appearance to make it look like unclickable area.
54 void SetRowEnabled(bool enabled
);
56 // Returns the relative position of the candidate label.
57 gfx::Point
GetCandidateLabelPosition() const;
60 friend class CandidateWindowViewTest
;
61 FRIEND_TEST_ALL_PREFIXES(CandidateWindowViewTest
, ShortcutSettingTest
);
62 // Overridden from View:
63 virtual bool OnMousePressed(const ui::MouseEvent
& event
) OVERRIDE
;
65 // Notifies labels of their new background colors. Called whenever the view's
66 // background color changes.
67 void UpdateLabelBackgroundColors();
69 // Zero-origin index in the current page.
72 // The orientation of the candidate view.
73 InputMethodLookupTable::Orientation orientation_
;
75 // The parent candidate window that contains this view.
76 CandidateWindowView
* parent_candidate_window_
;
78 // Views created in the class will be part of tree of |this|, so these
79 // child views will be deleted when |this| is deleted.
81 // The shortcut label renders shortcut numbers like 1, 2, and 3.
82 views::Label
* shortcut_label_
;
83 // The candidate label renders candidates.
84 views::Label
* candidate_label_
;
85 // The annotation label renders annotations.
86 views::Label
* annotation_label_
;
89 views::View
* infolist_icon_
;
90 bool infolist_icon_enabled_
;
92 DISALLOW_COPY_AND_ASSIGN(CandidateView
);
95 } // namespace input_method
96 } // namespace chromeos
98 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_CANDIDATE_VIEW_H_