OLD | NEW |
| (Empty) |
1 // Copyright (c) 2006-2008 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. | |
4 | |
5 #ifndef VIEWS_CONTROLS_TABBED_PANE_H_ | |
6 #define VIEWS_CONTROLS_TABBED_PANE_H_ | |
7 | |
8 #include "views/controls/native_control.h" | |
9 | |
10 namespace views { | |
11 | |
12 // The TabbedPane class is a view that shows tabs. When the user clicks on a | |
13 // tab, the associated view is displayed. | |
14 // TODO (jcampan): implement GetPreferredSize(). | |
15 class WidgetWin; | |
16 | |
17 class TabbedPane : public NativeControl { | |
18 public: | |
19 TabbedPane(); | |
20 virtual ~TabbedPane(); | |
21 | |
22 // An interface an object can implement to be notified about events within | |
23 // the TabbedPane. | |
24 class Listener { | |
25 public: | |
26 // Called when the tab at the specified |index| is selected by the user. | |
27 virtual void TabSelectedAt(int index) = 0; | |
28 }; | |
29 void SetListener(Listener* listener); | |
30 | |
31 // Adds a new tab at the end of this TabbedPane with the specified |title|. | |
32 // |contents| is the view displayed when the tab is selected and is owned by | |
33 // the TabbedPane. | |
34 void AddTab(const std::wstring& title, View* contents); | |
35 | |
36 // Adds a new tab at the specified |index| with the specified |title|. | |
37 // |contents| is the view displayed when the tab is selected and is owned by | |
38 // the TabbedPane. If |select_if_first_tab| is true and the tabbed pane is | |
39 // currently empty, the new tab is selected. If you pass in false for | |
40 // |select_if_first_tab| you need to explicitly invoke SelectTabAt, otherwise | |
41 // the tabbed pane will not have a valid selection. | |
42 void AddTabAtIndex(int index, | |
43 const std::wstring& title, | |
44 View* contents, | |
45 bool select_if_first_tab); | |
46 | |
47 // Removes the tab at the specified |index| and returns the associated content | |
48 // view. The caller becomes the owner of the returned view. | |
49 View* RemoveTabAtIndex(int index); | |
50 | |
51 // Selects the tab at the specified |index|, which must be valid. | |
52 void SelectTabAt(int index); | |
53 | |
54 // Selects the tab containing the specified |contents|, which must be valid. | |
55 void SelectTabForContents(const View* contents); | |
56 | |
57 // Returns the number of tabs. | |
58 int GetTabCount(); | |
59 | |
60 virtual HWND CreateNativeControl(HWND parent_container); | |
61 virtual LRESULT OnNotify(int w_param, LPNMHDR l_param); | |
62 | |
63 virtual void Layout(); | |
64 | |
65 virtual RootView* GetContentsRootView(); | |
66 virtual FocusTraversable* GetFocusTraversable(); | |
67 virtual void ViewHierarchyChanged(bool is_add, View *parent, View *child); | |
68 | |
69 private: | |
70 // Changes the contents view to the view associated with the tab at |index|. | |
71 void DoSelectTabAt(int index); | |
72 | |
73 // Returns the index of the tab containing the specified |contents|. | |
74 int GetIndexForContents(const View* contents) const; | |
75 | |
76 void ResizeContents(HWND tab_control); | |
77 | |
78 HWND tab_control_; | |
79 | |
80 // The views associated with the different tabs. | |
81 std::vector<View*> tab_views_; | |
82 | |
83 // The window displayed in the tab. | |
84 WidgetWin* content_window_; | |
85 | |
86 // The listener we notify about tab selection changes. | |
87 Listener* listener_; | |
88 | |
89 DISALLOW_EVIL_CONSTRUCTORS(TabbedPane); | |
90 }; | |
91 | |
92 } // namespace views | |
93 | |
94 #endif // #define VIEWS_CONTROLS_TABBED_PANE_H_ | |
OLD | NEW |