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) 365c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu void SetHighlighted(bool highlighted); 375c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu 385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) private: 395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) friend class CandidateWindowViewTest; 405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) FRIEND_TEST_ALL_PREFIXES(CandidateWindowViewTest, ShortcutSettingTest); 415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Overridden from views::CustomButton: 435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual void StateChanged() OVERRIDE; 445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Overridden from View: 465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual bool OnMouseDragged(const ui::MouseEvent& event) OVERRIDE; 475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual void Layout() OVERRIDE; 48cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual gfx::Size GetPreferredSize() const OVERRIDE; 495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // The orientation of the candidate view. 515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ui::CandidateWindow::Orientation orientation_; 525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Views created in the class will be part of tree of |this|, so these 545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // child views will be deleted when |this| is deleted. 555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // The shortcut label renders shortcut numbers like 1, 2, and 3. 575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) views::Label* shortcut_label_; 585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // The candidate label renders candidates. 595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) views::Label* candidate_label_; 605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // The annotation label renders annotations. 615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) views::Label* annotation_label_; 625c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu // The infolist icon. 635c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu views::View* infolist_icon_; 645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) int shortcut_width_; 665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) int candidate_width_; 675c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu bool highlighted_; 685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(CandidateView); 705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}; 715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} // namespace ime 735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} // namespace ash 745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#endif // ASH_IME_CANDIDATE_VIEW_H_ 76