Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef UI_VIEWS_CONTROLS_TABBED_PANE_TABBED_PANE_H_ | 5 #ifndef UI_VIEWS_CONTROLS_TABBED_PANE_TABBED_PANE_H_ |
| 6 #define UI_VIEWS_CONTROLS_TABBED_PANE_TABBED_PANE_H_ | 6 #define UI_VIEWS_CONTROLS_TABBED_PANE_TABBED_PANE_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 27 ~TabbedPane() override; | 27 ~TabbedPane() override; |
| 28 | 28 |
| 29 TabbedPaneListener* listener() const { return listener_; } | 29 TabbedPaneListener* listener() const { return listener_; } |
| 30 void set_listener(TabbedPaneListener* listener) { listener_ = listener; } | 30 void set_listener(TabbedPaneListener* listener) { listener_ = listener; } |
| 31 | 31 |
| 32 int selected_tab_index() const { return selected_tab_index_; } | 32 int selected_tab_index() const { return selected_tab_index_; } |
| 33 | 33 |
| 34 // Returns the number of tabs. | 34 // Returns the number of tabs. |
| 35 int GetTabCount(); | 35 int GetTabCount(); |
| 36 | 36 |
| 37 // Returns the contents of the selected tab or NULL if there is none. | |
| 38 View* GetSelectedTab(); | |
| 39 | |
| 40 // Adds a new tab at the end of this TabbedPane with the specified |title|. | 37 // Adds a new tab at the end of this TabbedPane with the specified |title|. |
| 41 // |contents| is the view displayed when the tab is selected and is owned by | 38 // |contents| is the view displayed when the tab is selected and is owned by |
| 42 // the TabbedPane. | 39 // the TabbedPane. |
| 43 void AddTab(const base::string16& title, View* contents); | 40 void AddTab(const base::string16& title, View* contents); |
| 44 | 41 |
| 45 // Adds a new tab at |index| with |title|. |contents| is the view displayed | 42 // Adds a new tab at |index| with |title|. |contents| is the view displayed |
| 46 // when the tab is selected and is owned by the TabbedPane. If the tabbed pane | 43 // when the tab is selected and is owned by the TabbedPane. If the tabbed pane |
| 47 // is currently empty, the new tab is selected. | 44 // is currently empty, the new tab is selected. |
| 48 void AddTabAtIndex(int index, const base::string16& title, View* contents); | 45 void AddTabAtIndex(int index, const base::string16& title, View* contents); |
| 49 | 46 |
| 50 // Selects the tab at |index|, which must be valid. | 47 // Selects the tab at |index|, which must be valid. |
| 51 void SelectTabAt(int index); | 48 void SelectTabAt(int index); |
| 52 | 49 |
| 53 // Selects |tab| (the tabstrip view, not its content) if it is valid. | 50 // Selects |tab| (the tabstrip view, not its content) if it is valid. |
| 54 void SelectTab(Tab* tab); | 51 void SelectTab(Tab* tab); |
| 55 | 52 |
| 56 // Overridden from View: | 53 // Overridden from View: |
| 57 gfx::Size GetPreferredSize() const override; | 54 gfx::Size GetPreferredSize() const override; |
| 58 const char* GetClassName() const override; | 55 const char* GetClassName() const override; |
| 59 | 56 |
| 57 // Returns the content View of the currently selected Tab. | |
| 58 View* GetSelectedTabViewForTesting(); | |
|
sky
2016/10/05 20:00:22
I'm not a fan of ForTesting public functions. They
Elly Fong-Jones
2016/10/06 16:15:30
Done.
| |
| 59 | |
| 60 // Gets the currently selected Tab (returned as a View, because the Tab class | |
| 61 // is private). | |
| 62 View* GetSelectedTabForTesting(); | |
| 63 | |
| 60 private: | 64 private: |
| 61 friend class TabStrip; | 65 friend class TabStrip; |
| 62 | 66 |
| 63 // Get the Tab (the tabstrip view, not its content) at the valid |index|. | 67 // Get the Tab (the tabstrip view, not its content) at the valid |index|. |
| 64 Tab* GetTabAt(int index); | 68 Tab* GetTabAt(int index); |
| 65 | 69 |
| 70 // Get the Tab (the tabstrip view, not its content) at the selected index. | |
| 71 Tab* GetSelectedTab(); | |
| 72 | |
| 73 // Moves the selection by |delta| tabs, where negative delta means leftwards | |
| 74 // and positive delta means rightwards. Returns whether the selection could be | |
| 75 // moved by that amount; the only way this can fail is if there is only one | |
| 76 // tab. | |
| 77 bool MoveSelectionBy(int delta); | |
| 78 | |
| 66 // Overridden from View: | 79 // Overridden from View: |
| 67 void Layout() override; | 80 void Layout() override; |
| 68 void ViewHierarchyChanged( | 81 void ViewHierarchyChanged( |
| 69 const ViewHierarchyChangedDetails& details) override; | 82 const ViewHierarchyChangedDetails& details) override; |
| 70 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; | 83 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; |
| 71 void OnFocus() override; | 84 bool OnKeyPressed(const ui::KeyEvent& event) override; |
| 72 void GetAccessibleState(ui::AXViewState* state) override; | 85 void GetAccessibleState(ui::AXViewState* state) override; |
| 73 | 86 |
| 74 // A listener notified when tab selection changes. Weak, not owned. | 87 // A listener notified when tab selection changes. Weak, not owned. |
| 75 TabbedPaneListener* listener_; | 88 TabbedPaneListener* listener_; |
| 76 | 89 |
| 77 // The tab strip and contents container. The child indices of these members | 90 // The tab strip and contents container. The child indices of these members |
| 78 // correspond to match each Tab with its respective content View. | 91 // correspond to match each Tab with its respective content View. |
| 79 TabStrip* tab_strip_; | 92 TabStrip* tab_strip_; |
| 80 View* contents_; | 93 View* contents_; |
| 81 | 94 |
| 82 // The selected tab index or -1 if invalid. | 95 // The selected tab index or -1 if invalid. |
| 83 int selected_tab_index_; | 96 int selected_tab_index_; |
| 84 | 97 |
| 85 DISALLOW_COPY_AND_ASSIGN(TabbedPane); | 98 DISALLOW_COPY_AND_ASSIGN(TabbedPane); |
| 86 }; | 99 }; |
| 87 | 100 |
| 88 } // namespace views | 101 } // namespace views |
| 89 | 102 |
| 90 #endif // UI_VIEWS_CONTROLS_TABBED_PANE_TABBED_PANE_H_ | 103 #endif // UI_VIEWS_CONTROLS_TABBED_PANE_TABBED_PANE_H_ |
| OLD | NEW |