OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_VIEWS_DEFAULT_NON_CLIENT_VIEW_H_ | 5 #ifndef CHROME_VIEWS_CUSTOM_FRAME_VIEW_H_ |
6 #define CHROME_VIEWS_DEFAULT_NON_CLIENT_VIEW_H_ | 6 #define CHROME_VIEWS_CUSTOM_FRAME_VIEW_H_ |
7 | 7 |
8 #include "chrome/views/button.h" | 8 #include "chrome/views/button.h" |
9 #include "chrome/views/custom_frame_window.h" | |
10 #include "chrome/views/non_client_view.h" | 9 #include "chrome/views/non_client_view.h" |
| 10 #include "chrome/views/window.h" |
11 #include "chrome/views/window_resources.h" | 11 #include "chrome/views/window_resources.h" |
12 | 12 |
13 namespace gfx{ | 13 namespace gfx{ |
14 class Size; | 14 class Size; |
15 class Path; | 15 class Path; |
16 class Point; | 16 class Point; |
17 } | 17 } |
18 class ChromeCanvas; | 18 class ChromeCanvas; |
19 | 19 |
20 namespace views { | 20 namespace views { |
21 | 21 |
22 class ClientView; | |
23 | |
24 /////////////////////////////////////////////////////////////////////////////// | 22 /////////////////////////////////////////////////////////////////////////////// |
25 // | 23 // |
26 // DefaultNonClientView | 24 // CustomFrameView |
27 // | 25 // |
28 // A ChromeView that provides the "frame" for CustomFrameWindows. This means | 26 // A ChromeView that provides the non client frame for Windows. This means |
29 // rendering the non-standard window caption, border, and controls. | 27 // rendering the non-standard window caption, border, and controls. |
30 // | 28 // |
31 //////////////////////////////////////////////////////////////////////////////// | 29 //////////////////////////////////////////////////////////////////////////////// |
32 class DefaultNonClientView : public NonClientView, | 30 class CustomFrameView : public NonClientFrameView, |
33 public BaseButton::ButtonListener { | 31 public BaseButton::ButtonListener { |
34 public: | 32 public: |
35 explicit DefaultNonClientView(CustomFrameWindow* container); | 33 explicit CustomFrameView(Window* frame); |
36 virtual ~DefaultNonClientView(); | 34 virtual ~CustomFrameView(); |
37 | 35 |
38 // Overridden from views::NonClientView: | 36 // Overridden from views::NonClientFrameView: |
39 virtual gfx::Rect CalculateClientAreaBounds(int width, int height) const; | 37 virtual gfx::Rect GetBoundsForClientView() const; |
40 virtual gfx::Size CalculateWindowSizeForClientSize(int width, | 38 virtual gfx::Rect GetWindowBoundsForClientBounds( |
41 int height) const; | 39 const gfx::Rect& client_bounds) const; |
42 virtual gfx::Point GetSystemMenuPoint() const; | 40 virtual gfx::Point GetSystemMenuPoint() const; |
43 virtual int NonClientHitTest(const gfx::Point& point); | 41 virtual int NonClientHitTest(const gfx::Point& point); |
44 virtual void GetWindowMask(const gfx::Size& size, gfx::Path* window_mask); | 42 virtual void GetWindowMask(const gfx::Size& size, gfx::Path* window_mask); |
45 virtual void EnableClose(bool enable); | 43 virtual void EnableClose(bool enable); |
46 virtual void ResetWindowControls(); | 44 virtual void ResetWindowControls(); |
47 | 45 |
48 // View overrides: | 46 // View overrides: |
49 virtual void Paint(ChromeCanvas* canvas); | 47 virtual void Paint(ChromeCanvas* canvas); |
50 virtual void Layout(); | 48 virtual void Layout(); |
51 virtual gfx::Size GetPreferredSize(); | 49 virtual gfx::Size GetPreferredSize(); |
52 virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child); | |
53 | 50 |
54 // BaseButton::ButtonListener implementation: | 51 // BaseButton::ButtonListener implementation: |
55 virtual void ButtonPressed(BaseButton* sender); | 52 virtual void ButtonPressed(BaseButton* sender); |
56 | 53 |
57 private: | 54 private: |
58 // Returns the thickness of the border that makes up the window frame edges. | 55 // Returns the thickness of the border that makes up the window frame edges. |
59 // This does not include any client edge. | 56 // This does not include any client edge. |
60 int FrameBorderThickness() const; | 57 int FrameBorderThickness() const; |
61 | 58 |
62 // Returns the thickness of the entire nonclient left, right, and bottom | 59 // Returns the thickness of the entire nonclient left, right, and bottom |
(...skipping 19 matching lines...) Expand all Loading... |
82 void PaintTitleBar(ChromeCanvas* canvas); | 79 void PaintTitleBar(ChromeCanvas* canvas); |
83 void PaintRestoredClientEdge(ChromeCanvas* canvas); | 80 void PaintRestoredClientEdge(ChromeCanvas* canvas); |
84 | 81 |
85 // Layout various sub-components of this view. | 82 // Layout various sub-components of this view. |
86 void LayoutWindowControls(); | 83 void LayoutWindowControls(); |
87 void LayoutTitleBar(); | 84 void LayoutTitleBar(); |
88 void LayoutClientView(); | 85 void LayoutClientView(); |
89 | 86 |
90 // Returns the resource collection to be used when rendering the window. | 87 // Returns the resource collection to be used when rendering the window. |
91 WindowResources* resources() const { | 88 WindowResources* resources() const { |
92 return container_->is_active() || paint_as_active() ? active_resources_ | 89 return frame_->is_active() || paint_as_active() ? active_resources_ |
93 : inactive_resources_; | 90 : inactive_resources_; |
94 } | 91 } |
95 | 92 |
96 // The View that provides the background for the window, and optionally | 93 // The bounds of the client view, in this view's coordinates. |
97 // dialog buttons. Note: the non-client view does _not_ own this view, the | 94 gfx::Rect client_view_bounds_; |
98 // container does. | |
99 ClientView* client_view_; | |
100 | 95 |
101 // The layout rect of the title, if visible. | 96 // The layout rect of the title, if visible. |
102 gfx::Rect title_bounds_; | 97 gfx::Rect title_bounds_; |
103 | 98 |
104 // Window controls. | 99 // Window controls. |
105 Button* close_button_; | 100 Button* close_button_; |
106 Button* restore_button_; | 101 Button* restore_button_; |
107 Button* maximize_button_; | 102 Button* maximize_button_; |
108 Button* minimize_button_; | 103 Button* minimize_button_; |
109 Button* system_menu_button_; // Uses the window icon if visible. | 104 Button* system_menu_button_; // Uses the window icon if visible. |
110 bool should_show_minmax_buttons_; | 105 bool should_show_minmax_buttons_; |
111 | 106 |
112 // The window that owns this view. | 107 // The window that owns this view. |
113 CustomFrameWindow* container_; | 108 Window* frame_; |
114 | 109 |
115 // Initialize various static resources. | 110 // Initialize various static resources. |
116 static void InitClass(); | 111 static void InitClass(); |
117 static WindowResources* active_resources_; | 112 static WindowResources* active_resources_; |
118 static WindowResources* inactive_resources_; | 113 static WindowResources* inactive_resources_; |
119 static ChromeFont title_font_; | 114 static ChromeFont title_font_; |
120 | 115 |
121 DISALLOW_EVIL_CONSTRUCTORS(DefaultNonClientView); | 116 DISALLOW_EVIL_CONSTRUCTORS(CustomFrameView); |
122 }; | 117 }; |
123 | 118 |
124 } // namespace views | 119 } // namespace views |
125 | 120 |
126 #endif // #ifndef CHROME_VIEWS_DEFAULT_NON_CLIENT_VIEW_H_ | 121 #endif // #ifndef CHROME_VIEWS_CUSTOM_FRAME_VIEW_H_ |
| 122 |
OLD | NEW |