Home | History | Annotate | Download | only in input_method
      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.
      4 
      5 #ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_CANDIDATE_VIEW_H_
      6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_CANDIDATE_VIEW_H_
      7 
      8 #include "base/gtest_prod_util.h"
      9 #include "chromeos/dbus/ibus/ibus_lookup_table.h"
     10 #include "ui/views/controls/label.h"
     11 #include "ui/views/view.h"
     12 
     13 namespace chromeos {
     14 namespace input_method {
     15 
     16 class CandidateWindowView;
     17 
     18 // CandidateView renderes a row of a candidate.
     19 class CandidateView : public views::View {
     20  public:
     21   CandidateView(CandidateWindowView* parent_candidate_window,
     22                 int index_in_page,
     23                 IBusLookupTable::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,
     30             int column_height);
     31 
     32   // Sets candidate text to the given text.
     33   void SetCandidateText(const string16& text);
     34 
     35   // Sets shortcut text to the given text.
     36   void SetShortcutText(const string16& text);
     37 
     38   // Sets annotation text to the given text.
     39   void SetAnnotationText(const string16& text);
     40 
     41   // Sets infolist icon.
     42   void SetInfolistIcon(bool enable);
     43 
     44   // Selects the candidate row. Changes the appearance to make it look
     45   // like a selected candidate.
     46   void Select();
     47 
     48   // Unselects the candidate row. Changes the appearance to make it look
     49   // like an unselected candidate.
     50   void Unselect();
     51 
     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);
     55 
     56   // Returns the relative position of the candidate label.
     57   gfx::Point GetCandidateLabelPosition() const;
     58 
     59  private:
     60   friend class CandidateWindowViewTest;
     61   FRIEND_TEST_ALL_PREFIXES(CandidateWindowViewTest, ShortcutSettingTest);
     62   // Overridden from View:
     63   virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE;
     64   virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
     65 
     66   // Selects the candidate located at the point.
     67   void SelectCandidateAt(const gfx::Point& location);
     68 
     69   // Notifies labels of their new background colors.  Called whenever the view's
     70   // background color changes.
     71   void UpdateLabelBackgroundColors();
     72 
     73   // Zero-origin index in the current page.
     74   int index_in_page_;
     75 
     76   // The orientation of the candidate view.
     77   IBusLookupTable::Orientation orientation_;
     78 
     79   // The parent candidate window that contains this view.
     80   CandidateWindowView* parent_candidate_window_;
     81 
     82   // Views created in the class will be part of tree of |this|, so these
     83   // child views will be deleted when |this| is deleted.
     84 
     85   // The shortcut label renders shortcut numbers like 1, 2, and 3.
     86   views::Label* shortcut_label_;
     87   // The candidate label renders candidates.
     88   views::Label* candidate_label_;
     89   // The annotation label renders annotations.
     90   views::Label* annotation_label_;
     91 
     92   // The infolist icon.
     93   views::View* infolist_icon_;
     94   bool infolist_icon_enabled_;
     95 
     96   DISALLOW_COPY_AND_ASSIGN(CandidateView);
     97 };
     98 
     99 }  // namespace input_method
    100 }  // namespace chromeos
    101 
    102 #endif  // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_CANDIDATE_VIEW_H_
    103