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; | |
16 class TabbedPaneListener; | 15 class TabbedPaneListener; |
16 class TabLayout; | |
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 bool use_native_win_control() { return use_native_win_control_; } | |
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 | 28 |
34 // Returns the number of tabs. | 29 // Returns the number of tabs. |
35 int GetTabCount(); | 30 int GetTabCount(); |
36 | 31 |
37 // Returns the index of the selected tab. | 32 // Returns the index of the selected tab. |
38 int GetSelectedTabIndex(); | 33 int GetSelectedTabIndex(); |
39 | 34 |
40 // Returns the contents of the selected tab. | 35 // Returns the contents of the selected tab. |
41 View* GetSelectedTab(); | 36 View* GetSelectedTab(); |
42 | 37 |
38 // Called by the TabStrip when its selected tab has changed. | |
39 void TabSelectionChanged(View* selected); | |
sky
2013/02/06 17:29:55
Cant this be implemented in terms of SelectTabAt?
msw
2013/02/07 00:29:37
Moot.
| |
40 | |
43 // Adds a new tab at the end of this TabbedPane with the specified |title|. | 41 // 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 | 42 // |contents| is the view displayed when the tab is selected and is owned by |
45 // the TabbedPane. | 43 // the TabbedPane. |
46 void AddTab(const string16& title, View* contents); | 44 void AddTab(const string16& title, View* contents); |
47 | 45 |
48 // Adds a new tab at |index| with |title|. | 46 // Adds a new tab at |index| with |title|. |
49 // |contents| is the view displayed when the tab is selected and is owned by | 47 // |contents| is the view displayed when the tab is selected and is owned by |
50 // the TabbedPane. If |select_if_first_tab| is true and the tabbed pane is | 48 // the TabbedPane. If |select_if_first_tab| is true and the tabbed pane is |
51 // currently empty, the new tab is selected. If you pass in false for | 49 // currently empty, the new tab is selected. If you pass in false for |
52 // |select_if_first_tab| you need to explicitly invoke SelectTabAt, otherwise | 50 // |select_if_first_tab| you need to explicitly invoke SelectTabAt, otherwise |
53 // the tabbed pane will not have a valid selection. | 51 // the tabbed pane will not have a valid selection. |
54 void AddTabAtIndex(int index, | 52 void AddTabAtIndex(int index, |
55 const string16& title, | 53 const string16& title, |
56 View* contents, | 54 View* contents, |
57 bool select_if_first_tab); | 55 bool select_if_first_tab); |
58 | 56 |
59 // Removes the tab at |index| and returns the associated content view. | 57 // Removes the tab at |index| and returns the associated content view. |
60 // The caller becomes the owner of the returned view. | 58 // The caller becomes the owner of the returned view. |
61 View* RemoveTabAtIndex(int index); | 59 View* RemoveTabAtIndex(int index); |
62 | 60 |
63 // Selects the tab at |index|, which must be valid. | 61 // Selects the tab at |index|, which must be valid. |
64 void SelectTabAt(int index); | 62 void SelectTabAt(int index); |
65 | 63 |
66 void SetAccessibleName(const string16& name); | 64 void SetAccessibleName(const string16& name); |
67 | 65 |
68 // Overridden from View: | 66 // Overridden from View: |
69 virtual gfx::Size GetPreferredSize() OVERRIDE; | 67 virtual gfx::Size GetPreferredSize() OVERRIDE; |
70 | 68 |
71 protected: | |
72 // The object that actually implements the tabbed-pane. | |
73 // Protected for tests access. | |
74 NativeTabbedPaneWrapper* native_tabbed_pane_; | |
75 | |
76 private: | 69 private: |
77 // The tabbed-pane's class name. | 70 // The tabbed-pane's class name. |
78 static const char kViewClassName[]; | 71 static const char kViewClassName[]; |
79 | 72 |
80 // We support Ctrl+Tab and Ctrl+Shift+Tab to navigate tabbed option pages. | 73 // We support Ctrl+Tab and Ctrl+Shift+Tab to navigate tabbed option pages. |
81 void LoadAccelerators(); | 74 void LoadAccelerators(); |
82 | 75 |
83 // Overridden from View: | 76 // Overridden from View: |
84 virtual void Layout() OVERRIDE; | 77 virtual void Layout() OVERRIDE; |
85 virtual void ViewHierarchyChanged(bool is_add, | 78 virtual void ViewHierarchyChanged(bool is_add, |
86 View* parent, | 79 View* parent, |
87 View* child) OVERRIDE; | 80 View* child) OVERRIDE; |
88 // Handles Ctrl+Tab and Ctrl+Shift+Tab navigation of pages. | 81 // Handles Ctrl+Tab and Ctrl+Shift+Tab navigation of pages. |
89 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; | 82 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; |
90 virtual std::string GetClassName() const OVERRIDE; | 83 virtual std::string GetClassName() const OVERRIDE; |
91 virtual void OnFocus() OVERRIDE; | 84 virtual void OnFocus() OVERRIDE; |
92 virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE; | |
93 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; | 85 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; |
94 | 86 |
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. | 87 // Our listener. Not owned. Notified when tab selection changes. |
100 TabbedPaneListener* listener_; | 88 TabbedPaneListener* listener_; |
101 | 89 |
102 // The accessible name of this tabbed pane. | 90 // The accessible name of this tabbed pane. |
103 string16 accessible_name_; | 91 string16 accessible_name_; |
104 | 92 |
93 // The layout manager we use for managing our tabs. | |
94 TabLayout* tab_layout_manager_; | |
95 | |
96 // TabStrip. | |
97 TabStrip* tab_strip_; | |
98 | |
99 // The content displayed in the tab. | |
100 View* content_view_; | |
101 | |
105 DISALLOW_COPY_AND_ASSIGN(TabbedPane); | 102 DISALLOW_COPY_AND_ASSIGN(TabbedPane); |
106 }; | 103 }; |
107 | 104 |
108 } // namespace views | 105 } // namespace views |
109 | 106 |
110 #endif // UI_VIEWS_CONTROLS_TABBED_PANE_TABBED_PANE_H_ | 107 #endif // UI_VIEWS_CONTROLS_TABBED_PANE_TABBED_PANE_H_ |
OLD | NEW |