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