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.
5 #ifndef UI_VIEWS_CONTROLS_TABBED_PANE_TABBED_PANE_H_
6 #define UI_VIEWS_CONTROLS_TABBED_PANE_TABBED_PANE_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/strings/string16.h"
11 #include "ui/views/view.h"
16 class TabbedPaneListener;
19 // TabbedPane is a view that shows tabs. When the user clicks on a tab, the
20 // associated view is displayed.
21 class VIEWS_EXPORT TabbedPane : public View {
23 // Internal class name.
24 static const char kViewClassName[];
26 // |draw_border| indicates whether the tabbed pane should draw a border
27 // around its boundary or not.
28 explicit TabbedPane(bool draw_border);
29 virtual ~TabbedPane();
31 TabbedPaneListener* listener() const { return listener_; }
32 void set_listener(TabbedPaneListener* listener) { listener_ = listener; }
34 int selected_tab_index() const { return selected_tab_index_; }
36 // Returns the number of tabs.
39 // Returns the contents of the selected tab or NULL if there is none.
40 View* GetSelectedTab();
42 // Adds a new tab at the end of this TabbedPane with the specified |title|.
43 // |contents| is the view displayed when the tab is selected and is owned by
45 void AddTab(const string16& title, View* contents);
47 // Adds a new tab at |index| with |title|. |contents| is the view displayed
48 // when the tab is selected and is owned by the TabbedPane. If the tabbed pane
49 // is currently empty, the new tab is selected.
50 void AddTabAtIndex(int index, const string16& title, View* contents);
52 // Selects the tab at |index|, which must be valid.
53 void SelectTabAt(int index);
55 // Selects |tab| (the tabstrip view, not its content) if it is valid.
56 void SelectTab(Tab* tab);
58 // Overridden from View:
59 virtual gfx::Size GetPreferredSize() OVERRIDE;
60 virtual const char* GetClassName() const OVERRIDE;
63 friend class TabStrip;
65 // Get the Tab (the tabstrip view, not its content) at the valid |index|.
66 Tab* GetTabAt(int index);
68 // Overridden from View:
69 virtual void Layout() OVERRIDE;
70 virtual void ViewHierarchyChanged(
71 const ViewHierarchyChangedDetails& details) OVERRIDE;
72 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE;
73 virtual void OnFocus() OVERRIDE;
74 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
76 // A listener notified when tab selection changes. Weak, not owned.
77 TabbedPaneListener* listener_;
79 // The tab strip and contents container. The child indices of these members
80 // correspond to match each Tab with its respective content View.
84 // The selected tab index or -1 if invalid.
85 int selected_tab_index_;
87 DISALLOW_COPY_AND_ASSIGN(TabbedPane);
92 #endif // UI_VIEWS_CONTROLS_TABBED_PANE_TABBED_PANE_H_