Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(775)

Side by Side Diff: ui/views/controls/tabbed_pane/tabbed_pane.h

Issue 12221130: Revert 181798 for excessive leaks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 Tab; 15 class NativeTabbedPaneWrapper;
16 class TabbedPaneListener; 16 class TabbedPaneListener;
17 class TabStrip;
18 17
19 // TabbedPane is a view that shows tabs. When the user clicks on a tab, the 18 // TabbedPane is a view that shows tabs. When the user clicks on a tab, the
20 // associated view is displayed. 19 // associated view is displayed.
21 class VIEWS_EXPORT TabbedPane : public View { 20 class VIEWS_EXPORT TabbedPane : public View {
22 public: 21 public:
23 TabbedPane(); 22 TabbedPane();
24 virtual ~TabbedPane(); 23 virtual ~TabbedPane();
25 24
26 TabbedPaneListener* listener() const { return listener_; } 25 TabbedPaneListener* listener() const { return listener_; }
27 void set_listener(TabbedPaneListener* listener) { listener_ = listener; } 26 void set_listener(TabbedPaneListener* listener) { listener_ = listener; }
28 27 #if defined(OS_WIN) && !defined(USE_AURA)
29 int selected_tab_index() const { return selected_tab_index_; } 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
30 33
31 // Returns the number of tabs. 34 // Returns the number of tabs.
32 int GetTabCount(); 35 int GetTabCount();
33 36
34 // Returns the contents of the selected tab or NULL if there is none. 37 // Returns the index of the selected tab.
38 int GetSelectedTabIndex();
39
40 // Returns the contents of the selected tab.
35 View* GetSelectedTab(); 41 View* GetSelectedTab();
36 42
37 // Adds a new tab at the end of this TabbedPane with the specified |title|. 43 // Adds a new tab at the end of this TabbedPane with the specified |title|.
38 // |contents| is the view displayed when the tab is selected and is owned by 44 // |contents| is the view displayed when the tab is selected and is owned by
39 // the TabbedPane. 45 // the TabbedPane.
40 void AddTab(const string16& title, View* contents); 46 void AddTab(const string16& title, View* contents);
41 47
42 // Adds a new tab at |index| with |title|. |contents| is the view displayed 48 // Adds a new tab at |index| with |title|.
43 // when the tab is selected and is owned by the TabbedPane. If the tabbed pane 49 // |contents| is the view displayed when the tab is selected and is owned by
44 // is currently empty, the new tab is selected. 50 // the TabbedPane. If |select_if_first_tab| is true and the tabbed pane is
45 void AddTabAtIndex(int index, const string16& title, View* contents); 51 // 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
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);
46 62
47 // Selects the tab at |index|, which must be valid. 63 // Selects the tab at |index|, which must be valid.
48 void SelectTabAt(int index); 64 void SelectTabAt(int index);
49 65
50 // Selects |tab| (the tabstrip view, not its content) if it is valid. 66 void SetAccessibleName(const string16& name);
51 void SelectTab(Tab* tab);
52 67
53 // Overridden from View: 68 // Overridden from View:
54 virtual gfx::Size GetPreferredSize() OVERRIDE; 69 virtual gfx::Size GetPreferredSize() OVERRIDE;
55 70
71 protected:
72 // The object that actually implements the tabbed-pane.
73 // Protected for tests access.
74 NativeTabbedPaneWrapper* native_tabbed_pane_;
75
56 private: 76 private:
57 // Get the Tab (the tabstrip view, not its content) at the valid |index|. 77 // The tabbed-pane's class name.
58 Tab* GetTabAt(int index); 78 static const char kViewClassName[];
79
80 // We support Ctrl+Tab and Ctrl+Shift+Tab to navigate tabbed option pages.
81 void LoadAccelerators();
59 82
60 // Overridden from View: 83 // Overridden from View:
61 virtual void Layout() OVERRIDE; 84 virtual void Layout() OVERRIDE;
62 virtual void ViewHierarchyChanged(bool is_add, 85 virtual void ViewHierarchyChanged(bool is_add,
63 View* parent, 86 View* parent,
64 View* child) OVERRIDE; 87 View* child) OVERRIDE;
88 // Handles Ctrl+Tab and Ctrl+Shift+Tab navigation of pages.
65 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; 89 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE;
66 virtual std::string GetClassName() const OVERRIDE; 90 virtual std::string GetClassName() const OVERRIDE;
67 virtual void OnFocus() OVERRIDE; 91 virtual void OnFocus() OVERRIDE;
92 virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE;
68 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; 93 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
69 94
70 // A listener notified when tab selection changes. Weak, not owned. 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 TabbedPaneListener* listener_; 100 TabbedPaneListener* listener_;
72 101
73 // The tab strip and contents container. The child indices of these members 102 // The accessible name of this tabbed pane.
74 // correspond to match each Tab with its respective content View. 103 string16 accessible_name_;
75 TabStrip* tab_strip_;
76 View* contents_;
77
78 // The selected tab index or -1 if invalid.
79 int selected_tab_index_;
80 104
81 DISALLOW_COPY_AND_ASSIGN(TabbedPane); 105 DISALLOW_COPY_AND_ASSIGN(TabbedPane);
82 }; 106 };
83 107
84 } // namespace views 108 } // namespace views
85 109
86 #endif // UI_VIEWS_CONTROLS_TABBED_PANE_TABBED_PANE_H_ 110 #endif // UI_VIEWS_CONTROLS_TABBED_PANE_TABBED_PANE_H_
OLDNEW
« no previous file with comments | « ui/views/controls/tabbed_pane/native_tabbed_pane_wrapper.h ('k') | ui/views/controls/tabbed_pane/tabbed_pane.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698