OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_FRAME_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_FRAME_VIEW_H_ |
6 #define CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_FRAME_VIEW_H_ | 6 #define CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_FRAME_VIEW_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/gtest_prod_util.h" | 9 #include "base/gtest_prod_util.h" |
10 #include "base/scoped_ptr.h" | |
10 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h" | 11 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h" |
11 #include "chrome/browser/ui/views/tab_icon_view.h" | 12 #include "chrome/browser/ui/views/tab_icon_view.h" |
13 #include "ui/base/models/simple_menu_model.h" | |
12 #include "views/controls/button/button.h" | 14 #include "views/controls/button/button.h" |
13 #include "views/controls/menu/view_menu_delegate.h" | 15 #include "views/controls/menu/view_menu_delegate.h" |
14 | 16 |
15 class PanelBrowserView; | 17 class PanelBrowserView; |
16 namespace views { | 18 namespace views { |
17 class ImageButton; | 19 class ImageButton; |
18 class Label; | 20 class Label; |
21 class Menu2; | |
19 class MenuButton; | 22 class MenuButton; |
20 } | 23 } |
21 | 24 |
22 class PanelBrowserFrameView : public BrowserNonClientFrameView, | 25 class PanelBrowserFrameView : public BrowserNonClientFrameView, |
23 public views::ButtonListener, | 26 public views::ButtonListener, |
24 public views::ViewMenuDelegate, | 27 public views::ViewMenuDelegate, |
28 public ui::SimpleMenuModel::Delegate, | |
25 public TabIconView::TabIconViewModel { | 29 public TabIconView::TabIconViewModel { |
26 public: | 30 public: |
27 PanelBrowserFrameView(BrowserFrame* frame, PanelBrowserView* browser_view); | 31 PanelBrowserFrameView(BrowserFrame* frame, PanelBrowserView* browser_view); |
28 virtual ~PanelBrowserFrameView(); | 32 virtual ~PanelBrowserFrameView(); |
29 | 33 |
30 void UpdateTitleBar(); | 34 void UpdateTitleBar(); |
31 void OnActivationChanged(bool active); | 35 void OnActivationChanged(bool active); |
32 | 36 |
33 protected: | 37 protected: |
34 // Overridden from BrowserNonClientFrameView: | 38 // Overridden from BrowserNonClientFrameView: |
(...skipping 23 matching lines...) Expand all Loading... | |
58 virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE; | 62 virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE; |
59 virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE; | 63 virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE; |
60 | 64 |
61 // Overridden from views::ButtonListener: | 65 // Overridden from views::ButtonListener: |
62 virtual void ButtonPressed(views::Button* sender, const views::Event& event) | 66 virtual void ButtonPressed(views::Button* sender, const views::Event& event) |
63 OVERRIDE; | 67 OVERRIDE; |
64 | 68 |
65 // Overridden from views::ViewMenuDelegate: | 69 // Overridden from views::ViewMenuDelegate: |
66 virtual void RunMenu(View* source, const gfx::Point& pt) OVERRIDE; | 70 virtual void RunMenu(View* source, const gfx::Point& pt) OVERRIDE; |
67 | 71 |
72 // Overridden from ui::SimpleMenuModel::Delegate: | |
73 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; | |
74 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; | |
75 virtual bool GetAcceleratorForCommandId( | |
76 int command_id, ui::Accelerator* accelerator) OVERRIDE; | |
77 virtual void ExecuteCommand(int command_id) OVERRIDE; | |
78 | |
68 // Overridden from TabIconView::TabIconViewModel: | 79 // Overridden from TabIconView::TabIconViewModel: |
69 virtual bool ShouldTabIconViewAnimate() const OVERRIDE; | 80 virtual bool ShouldTabIconViewAnimate() const OVERRIDE; |
70 virtual SkBitmap GetFaviconForTabIconView() OVERRIDE; | 81 virtual SkBitmap GetFaviconForTabIconView() OVERRIDE; |
71 | 82 |
72 private: | 83 private: |
73 friend class PanelBrowserViewTest; | 84 friend class PanelBrowserViewTest; |
74 FRIEND_TEST_ALL_PREFIXES(PanelBrowserViewTest, CreatePanel); | 85 FRIEND_TEST_ALL_PREFIXES(PanelBrowserViewTest, CreatePanel); |
86 FRIEND_TEST_ALL_PREFIXES(PanelBrowserViewTest, CreateOptionsMenu); | |
75 | 87 |
76 enum PaintState { | 88 enum PaintState { |
77 NOT_PAINTED, | 89 NOT_PAINTED, |
78 PAINT_AS_INACTIVE, | 90 PAINT_AS_INACTIVE, |
79 PAINT_AS_ACTIVE | 91 PAINT_AS_ACTIVE |
80 }; | 92 }; |
81 | 93 |
94 enum { | |
95 COMMAND_MINIMIZE_ALL, | |
96 COMMAND_RESTORE_ALL, | |
97 COMMAND_CLOSE_ALL, | |
98 COMMAND_ABOUT | |
99 }; | |
100 static const int kMinimizeAllCommand = 0; | |
jennb
2011/05/11 18:06:10
Forgot to delete these.
jianli
2011/05/11 18:31:31
Done.
| |
101 static const int kRestoreAllCommand = 1; | |
102 static const int kCloseAllCommand = 2; | |
103 static const int kAboutCommand = 3; | |
104 | |
82 // Returns the thickness of the entire nonclient left, right, and bottom | 105 // Returns the thickness of the entire nonclient left, right, and bottom |
83 // borders, including both the window frame and any client edge. | 106 // borders, including both the window frame and any client edge. |
84 int NonClientBorderThickness() const; | 107 int NonClientBorderThickness() const; |
85 | 108 |
86 // Returns the height of the entire nonclient top border, including the window | 109 // Returns the height of the entire nonclient top border, including the window |
87 // frame, any title area, and any connected client edge. | 110 // frame, any title area, and any connected client edge. |
88 int NonClientTopBorderHeight() const; | 111 int NonClientTopBorderHeight() const; |
89 | 112 |
90 // Update control styles to indicate if the title bar is active or not, i.e. | 113 // Update control styles to indicate if the title bar is active or not, i.e. |
91 // changing the font and color of title text. | 114 // changing the font and color of title text. |
92 void UpdateControlStyles(PaintState paint_state); | 115 void UpdateControlStyles(PaintState paint_state); |
93 | 116 |
94 // Custom draw the frame. | 117 // Custom draw the frame. |
95 void PaintFrameBorder(gfx::Canvas* canvas); | 118 void PaintFrameBorder(gfx::Canvas* canvas); |
96 void PaintClientEdge(gfx::Canvas* canvas); | 119 void PaintClientEdge(gfx::Canvas* canvas); |
97 | 120 |
121 void CreateOptionsMenu(); | |
122 void CreateOptionsMenuItems(); | |
123 | |
98 // The frame that hosts this view. This is a weak reference such that frame_ | 124 // The frame that hosts this view. This is a weak reference such that frame_ |
99 // will always be valid in the lifetime of this view. | 125 // will always be valid in the lifetime of this view. |
100 BrowserFrame* frame_; | 126 BrowserFrame* frame_; |
101 | 127 |
102 // The client view hosted within this non-client frame view that is | 128 // The client view hosted within this non-client frame view that is |
103 // guaranteed to be freed before the client view. | 129 // guaranteed to be freed before the client view. |
104 // (see comments about view hierarchies in non_client_view.h) | 130 // (see comments about view hierarchies in non_client_view.h) |
105 PanelBrowserView* browser_view_; | 131 PanelBrowserView* browser_view_; |
106 | 132 |
107 PaintState paint_state_; | 133 PaintState paint_state_; |
108 views::MenuButton* options_button_; | 134 views::MenuButton* options_button_; |
109 views::ImageButton* close_button_; | 135 views::ImageButton* close_button_; |
110 TabIconView* title_icon_; | 136 TabIconView* title_icon_; |
111 views::Label* title_label_; | 137 views::Label* title_label_; |
112 gfx::Rect client_view_bounds_; | 138 gfx::Rect client_view_bounds_; |
113 std::wstring accessible_name_; | 139 std::wstring accessible_name_; |
140 scoped_ptr<views::Menu2> options_menu_; | |
141 scoped_ptr<ui::SimpleMenuModel> options_menu_contents_; | |
114 | 142 |
115 DISALLOW_COPY_AND_ASSIGN(PanelBrowserFrameView); | 143 DISALLOW_COPY_AND_ASSIGN(PanelBrowserFrameView); |
116 }; | 144 }; |
117 | 145 |
118 #endif // CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_FRAME_VIEW_H_ | 146 #endif // CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_FRAME_VIEW_H_ |
OLD | NEW |