OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 VIEWS_CONTROLS_TABBED_PANE_NATIVE_TABBED_PANE_WIN_H_ | 5 #ifndef VIEWS_CONTROLS_TABBED_PANE_NATIVE_TABBED_PANE_WIN_H_ |
6 #define VIEWS_CONTROLS_TABBED_PANE_NATIVE_TABBED_PANE_WIN_H_ | 6 #define VIEWS_CONTROLS_TABBED_PANE_NATIVE_TABBED_PANE_WIN_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "views/controls/native_control_win.h" | 10 #include "views/controls/native_control_win.h" |
11 #include "views/controls/tabbed_pane/native_tabbed_pane_wrapper.h" | 11 #include "views/controls/tabbed_pane/native_tabbed_pane_wrapper.h" |
12 | 12 |
13 namespace views { | 13 namespace views { |
14 | 14 |
15 class WidgetWin; | 15 class WidgetWin; |
| 16 class TabLayout; |
16 | 17 |
17 class NativeTabbedPaneWin : public NativeControlWin, | 18 class NativeTabbedPaneWin : public NativeControlWin, |
18 public NativeTabbedPaneWrapper { | 19 public NativeTabbedPaneWrapper { |
19 public: | 20 public: |
20 explicit NativeTabbedPaneWin(TabbedPane* tabbed_pane); | 21 explicit NativeTabbedPaneWin(TabbedPane* tabbed_pane); |
21 virtual ~NativeTabbedPaneWin(); | 22 virtual ~NativeTabbedPaneWin(); |
22 | 23 |
23 // NativeTabbedPaneWrapper implementation: | 24 // NativeTabbedPaneWrapper implementation: |
24 virtual void AddTab(const std::wstring& title, View* contents); | 25 virtual void AddTab(const std::wstring& title, View* contents); |
25 virtual void AddTabAtIndex(int index, | 26 virtual void AddTabAtIndex(int index, |
26 const std::wstring& title, | 27 const std::wstring& title, |
27 View* contents, | 28 View* contents, |
28 bool select_if_first_tab); | 29 bool select_if_first_tab); |
29 virtual View* RemoveTabAtIndex(int index); | 30 virtual View* RemoveTabAtIndex(int index); |
30 virtual void SelectTabAt(int index); | 31 virtual void SelectTabAt(int index); |
31 virtual int GetTabCount(); | 32 virtual int GetTabCount(); |
32 virtual int GetSelectedTabIndex(); | 33 virtual int GetSelectedTabIndex(); |
33 virtual View* GetSelectedTab(); | 34 virtual View* GetSelectedTab(); |
34 virtual View* GetView(); | 35 virtual View* GetView(); |
35 virtual void SetFocus(); | 36 virtual void SetFocus(); |
| 37 virtual gfx::Size GetPreferredSize(); |
36 virtual gfx::NativeView GetTestingHandle() const; | 38 virtual gfx::NativeView GetTestingHandle() const; |
37 | 39 |
38 // NativeControlWin overrides. | 40 // NativeControlWin overrides. |
39 virtual void CreateNativeControl(); | 41 virtual void CreateNativeControl(); |
40 virtual bool ProcessMessage(UINT message, | 42 virtual bool ProcessMessage(UINT message, |
41 WPARAM w_param, | 43 WPARAM w_param, |
42 LPARAM l_param, | 44 LPARAM l_param, |
43 LRESULT* result); | 45 LRESULT* result); |
44 | 46 |
45 // View overrides: | 47 // View overrides: |
46 virtual void Layout(); | 48 virtual void Layout(); |
47 virtual FocusTraversable* GetFocusTraversable(); | 49 virtual FocusTraversable* GetFocusTraversable(); |
48 virtual void ViewHierarchyChanged(bool is_add, View *parent, View *child); | 50 virtual void ViewHierarchyChanged(bool is_add, View *parent, View *child); |
49 | 51 |
50 virtual Widget* child_widget() { | 52 virtual Widget* child_widget() { |
51 return reinterpret_cast<Widget*>(content_window_); | 53 return reinterpret_cast<Widget*>(content_window_); |
52 } | 54 } |
53 | 55 |
54 private: | 56 private: |
55 // Called upon creation of native control to initialize tabs that are added | 57 // Called upon creation of native control to initialize tabs that are added |
56 // before the native control is created. | 58 // before the native control is created. |
57 void InitializeTabs(); | 59 void InitializeTabs(); |
58 | 60 |
59 // Adds a tab with the given content to native control at the given index. | 61 // Adds a tab with the given content to native control at the given index. |
60 void AddNativeTab(int index, const std::wstring& title, View* contents); | 62 void AddNativeTab(int index, const std::wstring& title); |
61 | 63 |
62 // Changes the contents view to the view associated with the tab at |index|. | 64 // Changes the contents view to the view associated with the tab at |index|. |
63 // |invoke_listener| controls if this methold should invoke the | 65 // |invoke_listener| controls if this methold should invoke the |
64 // Listener::TabSelectedAt callback. | 66 // Listener::TabSelectedAt callback. |
65 void DoSelectTabAt(int index, boolean invoke_listener); | 67 void DoSelectTabAt(int index, boolean invoke_listener); |
66 | 68 |
67 // Resizes the HWND control to macth the size of the containing view. | 69 // Resizes the HWND control to macth the size of the containing view. |
68 void ResizeContents(); | 70 void ResizeContents(); |
69 | 71 |
70 // The tabbed-pane we are bound to. | 72 // The tabbed-pane we are bound to. |
71 TabbedPane* tabbed_pane_; | 73 TabbedPane* tabbed_pane_; |
72 | 74 |
| 75 // The layout manager we use for managing our tabs. |
| 76 TabLayout* tab_layout_manager_; |
| 77 |
73 // The views associated with the different tabs. | 78 // The views associated with the different tabs. |
74 std::vector<View*> tab_views_; | 79 std::vector<View*> tab_views_; |
75 | 80 |
76 // The tab's title strings. | 81 // The tab's title strings. |
77 std::vector<const std::wstring> tab_titles_; | 82 std::vector<const std::wstring> tab_titles_; |
78 | 83 |
79 // The index of the selected tab. | 84 // The index of the selected tab. |
80 int selected_index_; | 85 int selected_index_; |
81 | 86 |
82 // The window displayed in the tab. | 87 // The window displayed in the tab. |
83 WidgetWin* content_window_; | 88 WidgetWin* content_window_; |
84 | 89 |
85 DISALLOW_COPY_AND_ASSIGN(NativeTabbedPaneWin); | 90 DISALLOW_COPY_AND_ASSIGN(NativeTabbedPaneWin); |
86 }; | 91 }; |
87 | 92 |
88 } // namespace views | 93 } // namespace views |
89 | 94 |
90 #endif // VIEWS_CONTROLS_TABBED_PANE_NATIVE_TABBED_PANE_WIN_H_ | 95 #endif // VIEWS_CONTROLS_TABBED_PANE_NATIVE_TABBED_PANE_WIN_H_ |
OLD | NEW |