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/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/string16.h" | 10 #include "base/string16.h" |
11 #include "ui/views/view.h" | 11 #include "ui/views/view.h" |
12 | 12 |
13 namespace views { | 13 namespace views { |
14 | 14 |
15 class NativeTabbedPaneWrapper; | 15 class Tab; |
16 class TabbedPaneListener; | 16 class TabbedPaneListener; |
17 class TabStrip; | |
17 | 18 |
18 // TabbedPane is a view that shows tabs. When the user clicks on a tab, the | 19 // TabbedPane is a view that shows tabs. When the user clicks on a tab, the |
19 // associated view is displayed. | 20 // associated view is displayed. |
20 class VIEWS_EXPORT TabbedPane : public View { | 21 class VIEWS_EXPORT TabbedPane : public View { |
21 public: | 22 public: |
22 TabbedPane(); | 23 TabbedPane(); |
23 virtual ~TabbedPane(); | 24 virtual ~TabbedPane(); |
24 | 25 |
25 TabbedPaneListener* listener() const { return listener_; } | 26 TabbedPaneListener* listener() const { return listener_; } |
26 void set_listener(TabbedPaneListener* listener) { listener_ = listener; } | 27 void set_listener(TabbedPaneListener* listener) { listener_ = listener; } |
27 #if defined(OS_WIN) && !defined(USE_AURA) | 28 |
28 bool use_native_win_control() { return use_native_win_control_; } | 29 int selected_tab_index() const { return selected_tab_index_; } |
29 void set_use_native_win_control(bool use_native_win_control) { | |
30 use_native_win_control_ = use_native_win_control; | |
31 } | |
32 #endif | |
33 | 30 |
34 // Returns the number of tabs. | 31 // Returns the number of tabs. |
35 int GetTabCount(); | 32 int GetTabCount(); |
36 | 33 |
37 // Returns the index of the selected tab. | 34 // Returns the contents of the selected tab or NULL if there is none. |
38 int GetSelectedTabIndex(); | |
39 | |
40 // Returns the contents of the selected tab. | |
41 View* GetSelectedTab(); | 35 View* GetSelectedTab(); |
42 | 36 |
43 // 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|. |
44 // |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 |
45 // the TabbedPane. | 39 // the TabbedPane. |
46 void AddTab(const string16& title, View* contents); | 40 void AddTab(const string16& title, View* contents); |
47 | 41 |
48 // Adds a new tab at |index| with |title|. | 42 // Adds a new tab at |index| with |title|. |contents| is the view displayed |
49 // |contents| is the view displayed when the tab is selected and is owned by | 43 // when the tab is selected and is owned by the TabbedPane. If the tabbed pane |
50 // the TabbedPane. If |select_if_first_tab| is true and the tabbed pane is | 44 // is currently empty, the new tab is selected. |
51 // currently empty, the new tab is selected. If you pass in false for | 45 void AddTabAtIndex(int index, const string16& title, View* contents); |
52 // |select_if_first_tab| you need to explicitly invoke SelectTabAt, otherwise | |
53 // the tabbed pane will not have a valid selection. | |
54 void AddTabAtIndex(int index, | |
55 const string16& title, | |
56 View* contents, | |
57 bool select_if_first_tab); | |
58 | |
59 // Removes the tab at |index| and returns the associated content view. | |
60 // The caller becomes the owner of the returned view. | |
61 View* RemoveTabAtIndex(int index); | |
62 | 46 |
63 // Selects the tab at |index|, which must be valid. | 47 // Selects the tab at |index|, which must be valid. |
64 void SelectTabAt(int index); | 48 void SelectTabAt(int index); |
65 | 49 |
66 void SetAccessibleName(const string16& name); | 50 // Selects |tab| if it is valid. |
sky
2013/02/11 16:26:36
Document what |tab| is.
msw
2013/02/11 20:41:43
Done (and changed to take a Tab*).
| |
51 void SelectTab(View* tab); | |
67 | 52 |
68 // Overridden from View: | 53 // Overridden from View: |
69 virtual gfx::Size GetPreferredSize() OVERRIDE; | 54 virtual gfx::Size GetPreferredSize() OVERRIDE; |
70 | 55 |
71 protected: | |
72 // The object that actually implements the tabbed-pane. | |
73 // Protected for tests access. | |
74 NativeTabbedPaneWrapper* native_tabbed_pane_; | |
75 | |
76 private: | 56 private: |
77 // The tabbed-pane's class name. | 57 // Returns the Tab at |index|, which must be valid. |
78 static const char kViewClassName[]; | 58 Tab* GetTabAt(int index); |
79 | |
80 // We support Ctrl+Tab and Ctrl+Shift+Tab to navigate tabbed option pages. | |
81 void LoadAccelerators(); | |
82 | 59 |
83 // Overridden from View: | 60 // Overridden from View: |
84 virtual void Layout() OVERRIDE; | 61 virtual void Layout() OVERRIDE; |
85 virtual void ViewHierarchyChanged(bool is_add, | 62 virtual void ViewHierarchyChanged(bool is_add, |
86 View* parent, | 63 View* parent, |
87 View* child) OVERRIDE; | 64 View* child) OVERRIDE; |
88 // Handles Ctrl+Tab and Ctrl+Shift+Tab navigation of pages. | 65 // Handles Ctrl+Tab and Ctrl+Shift+Tab navigation of pages. |
89 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; | 66 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; |
90 virtual std::string GetClassName() const OVERRIDE; | 67 virtual std::string GetClassName() const OVERRIDE; |
91 virtual void OnFocus() OVERRIDE; | 68 virtual void OnFocus() OVERRIDE; |
92 virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE; | |
93 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; | 69 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; |
94 | 70 |
95 #if defined(OS_WIN) && !defined(USE_AURA) | |
96 bool use_native_win_control_; | |
97 #endif | |
98 | |
99 // Our listener. Not owned. Notified when tab selection changes. | 71 // Our listener. Not owned. Notified when tab selection changes. |
100 TabbedPaneListener* listener_; | 72 TabbedPaneListener* listener_; |
101 | 73 |
102 // The accessible name of this tabbed pane. | 74 // The tab strip and the tab content view container. |
103 string16 accessible_name_; | 75 TabStrip* tab_strip_; |
76 View* tabs_; | |
77 | |
78 // The selected tab index or -1 if invalid. | |
79 int selected_tab_index_; | |
104 | 80 |
105 DISALLOW_COPY_AND_ASSIGN(TabbedPane); | 81 DISALLOW_COPY_AND_ASSIGN(TabbedPane); |
106 }; | 82 }; |
107 | 83 |
108 } // namespace views | 84 } // namespace views |
109 | 85 |
110 #endif // UI_VIEWS_CONTROLS_TABBED_PANE_TABBED_PANE_H_ | 86 #endif // UI_VIEWS_CONTROLS_TABBED_PANE_TABBED_PANE_H_ |
OLD | NEW |