candidate_view.h revision 5d1f7b1de12d16ceb2c938c56701a3e8bfa558f7
15d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved. 25d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// found in the LICENSE file. 45d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 55d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#ifndef ASH_IME_CANDIDATE_VIEW_H_ 65d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#define ASH_IME_CANDIDATE_VIEW_H_ 75d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 85d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ash/ash_export.h" 95d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "base/gtest_prod_util.h" 105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ui/base/ime/candidate_window.h" 115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ui/views/controls/button/custom_button.h" 125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ui/views/controls/label.h" 135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ui/views/view.h" 145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)namespace ash { 165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)namespace ime { 175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// CandidateView renderes a row of a candidate. 195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class ASH_EXPORT CandidateView : public views::CustomButton { 205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) public: 215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) CandidateView(views::ButtonListener* listener, 225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ui::CandidateWindow::Orientation orientation); 235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual ~CandidateView() {} 245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void GetPreferredWidths(int* shortcut_width, 265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) int* candidate_width); 275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void SetWidths(int shortcut_width, 295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) int candidate_width); 305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void SetEntry(const ui::CandidateWindow::Entry& entry); 325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Sets infolist icon. 345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void SetInfolistIcon(bool enable); 355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) private: 375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) friend class CandidateWindowViewTest; 385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) FRIEND_TEST_ALL_PREFIXES(CandidateWindowViewTest, ShortcutSettingTest); 395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Overridden from views::CustomButton: 415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual void StateChanged() OVERRIDE; 425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Overridden from View: 445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual bool OnMouseDragged(const ui::MouseEvent& event) OVERRIDE; 455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual void Layout() OVERRIDE; 465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual gfx::Size GetPreferredSize() OVERRIDE; 475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // The orientation of the candidate view. 495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ui::CandidateWindow::Orientation orientation_; 505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Views created in the class will be part of tree of |this|, so these 525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // child views will be deleted when |this| is deleted. 535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // The shortcut label renders shortcut numbers like 1, 2, and 3. 555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) views::Label* shortcut_label_; 565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // The candidate label renders candidates. 575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) views::Label* candidate_label_; 585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // The annotation label renders annotations. 595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) views::Label* annotation_label_; 605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) int shortcut_width_; 625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) int candidate_width_; 635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // The infolist icon. 655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) views::View* infolist_icon_; 665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(CandidateView); 685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}; 695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} // namespace ime 715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} // namespace ash 725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#endif // ASH_IME_CANDIDATE_VIEW_H_ 74