OLD | NEW |
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 CHROME_BROWSER_UI_VIEWS_CONSTRAINED_WINDOW_FRAME_SIMPLE_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_CONSTRAINED_WINDOW_FRAME_SIMPLE_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_CONSTRAINED_WINDOW_FRAME_SIMPLE_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_CONSTRAINED_WINDOW_FRAME_SIMPLE_H_ |
7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "ui/views/controls/button/button.h" |
8 #include "ui/views/window/non_client_view.h" | 10 #include "ui/views/window/non_client_view.h" |
9 | 11 |
10 class ConstrainedWindowViews; | 12 class ConstrainedWindowViews; |
11 | 13 |
| 14 namespace views { |
| 15 class ImageButton; |
| 16 class Label; |
| 17 class LayoutManager; |
| 18 } |
| 19 |
12 //////////////////////////////////////////////////////////////////////////////// | 20 //////////////////////////////////////////////////////////////////////////////// |
13 // ConstrainedWindowFrameView | 21 // ConstrainedWindowFrameView |
14 // Provides a custom Window frame for ConstrainedWindowViews. | 22 // Provides a custom Window frame for ConstrainedWindowViews. |
15 // Implements a simple window with a minimal frame. | 23 // Implements a simple window with a minimal frame. |
16 class ConstrainedWindowFrameSimple : public views::NonClientFrameView { | 24 class ConstrainedWindowFrameSimple : public views::NonClientFrameView, |
| 25 public views::ButtonListener { |
17 public: | 26 public: |
| 27 // Contains references to relevant views in the header. The header |
| 28 // must be non-NULL. |
| 29 struct HeaderViews { |
| 30 HeaderViews(views::View* header, |
| 31 views::Label* title_label, |
| 32 views::Button* close_button); |
| 33 |
| 34 views::View* header; |
| 35 views::Label* title_label; |
| 36 views::Button* close_button; |
| 37 }; |
| 38 |
18 explicit ConstrainedWindowFrameSimple(ConstrainedWindowViews* container); | 39 explicit ConstrainedWindowFrameSimple(ConstrainedWindowViews* container); |
19 virtual ~ConstrainedWindowFrameSimple() {} | 40 virtual ~ConstrainedWindowFrameSimple(); |
| 41 |
| 42 // SetHeaderView assumes ownership of the passed parameter. |
| 43 void SetHeaderView(HeaderViews* header_views); |
20 | 44 |
21 private: | 45 private: |
22 // Overridden from views::NonClientFrameView: | 46 // Overridden from views::NonClientFrameView: |
23 virtual gfx::Rect GetBoundsForClientView() const OVERRIDE; | 47 virtual gfx::Rect GetBoundsForClientView() const OVERRIDE; |
24 virtual gfx::Rect GetWindowBoundsForClientBounds( | 48 virtual gfx::Rect GetWindowBoundsForClientBounds( |
25 const gfx::Rect& client_bounds) const OVERRIDE; | 49 const gfx::Rect& client_bounds) const OVERRIDE; |
26 virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE; | 50 virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE; |
27 virtual void GetWindowMask(const gfx::Size& size, | 51 virtual void GetWindowMask(const gfx::Size& size, |
28 gfx::Path* window_mask) OVERRIDE {} | 52 gfx::Path* window_mask) OVERRIDE; |
29 virtual void ResetWindowControls() OVERRIDE {} | 53 virtual void ResetWindowControls() OVERRIDE; |
30 virtual void UpdateWindowIcon() OVERRIDE {} | 54 virtual void UpdateWindowIcon() OVERRIDE; |
31 virtual void UpdateWindowTitle() OVERRIDE {} | 55 virtual void UpdateWindowTitle() OVERRIDE; |
| 56 |
| 57 // Overridden from View: |
| 58 virtual gfx::Size GetPreferredSize() OVERRIDE; |
| 59 |
| 60 // Overridden from ButtonListener |
| 61 virtual void ButtonPressed(views::Button* sender, |
| 62 const ui::Event& event) OVERRIDE; |
| 63 |
| 64 HeaderViews* CreateDefaultHeaderView(); |
| 65 |
| 66 views::ImageButton* CreateCloseButton(); |
| 67 |
| 68 ConstrainedWindowViews* container_; |
| 69 |
| 70 views::LayoutManager* layout_; |
| 71 |
| 72 scoped_ptr<HeaderViews> header_views_; |
32 | 73 |
33 DISALLOW_COPY_AND_ASSIGN(ConstrainedWindowFrameSimple); | 74 DISALLOW_COPY_AND_ASSIGN(ConstrainedWindowFrameSimple); |
34 }; | 75 }; |
35 #endif // CHROME_BROWSER_UI_VIEWS_CONSTRAINED_WINDOW_FRAME_SIMPLE_H_ | 76 #endif // CHROME_BROWSER_UI_VIEWS_CONSTRAINED_WINDOW_FRAME_SIMPLE_H_ |
OLD | NEW |