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 ASH_IME_CANDIDATE_VIEW_H_
6 #define ASH_IME_CANDIDATE_VIEW_H_
8 #include "ash/ash_export.h"
9 #include "base/gtest_prod_util.h"
10 #include "ui/base/ime/candidate_window.h"
11 #include "ui/views/controls/button/custom_button.h"
12 #include "ui/views/controls/label.h"
13 #include "ui/views/view.h"
18 // CandidateView renderes a row of a candidate.
19 class ASH_EXPORT CandidateView
: public views::CustomButton
{
21 CandidateView(views::ButtonListener
* listener
,
22 ui::CandidateWindow::Orientation orientation
);
23 virtual ~CandidateView() {}
25 void GetPreferredWidths(int* shortcut_width
,
26 int* candidate_width
);
28 void SetWidths(int shortcut_width
,
31 void SetEntry(const ui::CandidateWindow::Entry
& entry
);
33 // Sets infolist icon.
34 void SetInfolistIcon(bool enable
);
37 friend class CandidateWindowViewTest
;
38 FRIEND_TEST_ALL_PREFIXES(CandidateWindowViewTest
, ShortcutSettingTest
);
40 // Overridden from views::CustomButton:
41 virtual void StateChanged() OVERRIDE
;
43 // Overridden from View:
44 virtual bool OnMouseDragged(const ui::MouseEvent
& event
) OVERRIDE
;
45 virtual void Layout() OVERRIDE
;
46 virtual gfx::Size
GetPreferredSize() OVERRIDE
;
48 // The orientation of the candidate view.
49 ui::CandidateWindow::Orientation orientation_
;
51 // Views created in the class will be part of tree of |this|, so these
52 // child views will be deleted when |this| is deleted.
54 // The shortcut label renders shortcut numbers like 1, 2, and 3.
55 views::Label
* shortcut_label_
;
56 // The candidate label renders candidates.
57 views::Label
* candidate_label_
;
58 // The annotation label renders annotations.
59 views::Label
* annotation_label_
;
65 views::View
* infolist_icon_
;
67 DISALLOW_COPY_AND_ASSIGN(CandidateView
);
73 #endif // ASH_IME_CANDIDATE_VIEW_H_