| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_NON_CLIENT_VIEW_H_ | 5 #ifndef CHROME_VIEWS_NON_CLIENT_VIEW_H_ |
| 6 #define CHROME_VIEWS_NON_CLIENT_VIEW_H_ | 6 #define CHROME_VIEWS_NON_CLIENT_VIEW_H_ |
| 7 | 7 |
| 8 #include "chrome/views/view.h" | 8 #include "chrome/views/view.h" |
| 9 #include "chrome/views/client_view.h" |
| 9 | 10 |
| 10 namespace gfx { | 11 namespace gfx { |
| 11 class Path; | 12 class Path; |
| 12 } | 13 } |
| 13 | 14 |
| 14 namespace views { | 15 namespace views { |
| 15 | 16 |
| 16 class ClientView; | |
| 17 | |
| 18 /////////////////////////////////////////////////////////////////////////////// | 17 /////////////////////////////////////////////////////////////////////////////// |
| 19 // NonClientView | 18 // NonClientView |
| 20 // | 19 // |
| 21 // An object implementing the NonClientView interface is a View that provides | 20 // An object implementing the NonClientView interface is a View that provides |
| 22 // the "non-client" areas of a window. This is the area that typically | 21 // the "non-client" areas of a window. This is the area that typically |
| 23 // encompasses the window frame - title bar, sizing borders and window | 22 // encompasses the window frame - title bar, sizing borders and window |
| 24 // controls. This interface provides methods that allow a specific | 23 // controls. This interface provides methods that allow a specific |
| 25 // presentation to define non-client areas for windows hit testing, the shape | 24 // presentation to define non-client areas for windows hit testing, the shape |
| 26 // of the window, and other window-related information. | 25 // of the window, and other window-related information. |
| 27 // | 26 // |
| 28 class NonClientView : public View { | 27 class NonClientView : public View { |
| 29 public: | 28 public: |
| 29 NonClientView(); |
| 30 virtual ~NonClientView(); |
| 31 |
| 30 // Various edges of the frame border have a 1 px shadow along their edges; in | 32 // Various edges of the frame border have a 1 px shadow along their edges; in |
| 31 // a few cases we shift elements based on this amount for visual appeal. | 33 // a few cases we shift elements based on this amount for visual appeal. |
| 32 static const int kFrameShadowThickness; | 34 static const int kFrameShadowThickness; |
| 33 // In restored mode, we draw a 1 px edge around the content area inside the | 35 // In restored mode, we draw a 1 px edge around the content area inside the |
| 34 // frame border. | 36 // frame border. |
| 35 static const int kClientEdgeThickness; | 37 static const int kClientEdgeThickness; |
| 36 | 38 |
| 39 // Returns true if the ClientView determines that the containing window can be |
| 40 // closed, false otherwise. |
| 41 bool CanClose() const; |
| 42 |
| 43 // Called by the containing Window when it is closed. |
| 44 void WindowClosing(); |
| 45 |
| 37 // Calculates the bounds of the client area of the window assuming the | 46 // Calculates the bounds of the client area of the window assuming the |
| 38 // window is sized to |width| and |height|. | 47 // window is sized to |width| and |height|. |
| 39 virtual gfx::Rect CalculateClientAreaBounds(int width, | 48 virtual gfx::Rect CalculateClientAreaBounds(int width, int height) const; |
| 40 int height) const = 0; | |
| 41 | 49 |
| 42 // Calculates the size of window required to display a client area of the | 50 // Calculates the size of window required to display a client area of the |
| 43 // specified width and height. | 51 // specified width and height. |
| 44 virtual gfx::Size CalculateWindowSizeForClientSize(int width, | 52 virtual gfx::Size CalculateWindowSizeForClientSize(int width, |
| 45 int height) const = 0; | 53 int height) const; |
| 46 | 54 |
| 47 // Returns the point, in screen coordinates, where the system menu should | 55 // Returns the point, in screen coordinates, where the system menu should |
| 48 // be shown so it shows up anchored to the system menu icon. | 56 // be shown so it shows up anchored to the system menu icon. |
| 49 virtual gfx::Point GetSystemMenuPoint() const = 0; | 57 virtual gfx::Point GetSystemMenuPoint() const; |
| 50 | 58 |
| 51 // Determines the windows HT* code when the mouse cursor is at the | 59 // Determines the windows HT* code when the mouse cursor is at the |
| 52 // specified point, in window coordinates. | 60 // specified point, in window coordinates. |
| 53 virtual int NonClientHitTest(const gfx::Point& point) = 0; | 61 virtual int NonClientHitTest(const gfx::Point& point); |
| 54 | 62 |
| 55 // Returns a mask to be used to clip the top level window for the given | 63 // Returns a mask to be used to clip the top level window for the given |
| 56 // size. This is used to create the non-rectangular window shape. | 64 // size. This is used to create the non-rectangular window shape. |
| 57 virtual void GetWindowMask(const gfx::Size& size, | 65 virtual void GetWindowMask(const gfx::Size& size, |
| 58 gfx::Path* window_mask) = 0; | 66 gfx::Path* window_mask); |
| 59 | 67 |
| 60 // Toggles the enable state for the Close button (and the Close menu item in | 68 // Toggles the enable state for the Close button (and the Close menu item in |
| 61 // the system menu). | 69 // the system menu). |
| 62 virtual void EnableClose(bool enable) = 0; | 70 virtual void EnableClose(bool enable); |
| 63 | 71 |
| 64 // Tells the window controls as rendered by the NonClientView to reset | 72 // Tells the window controls as rendered by the NonClientView to reset |
| 65 // themselves to a normal state. This happens in situations where the | 73 // themselves to a normal state. This happens in situations where the |
| 66 // containing window does not receive a normal sequences of messages that | 74 // containing window does not receive a normal sequences of messages that |
| 67 // would lead to the controls returning to this normal state naturally, e.g. | 75 // would lead to the controls returning to this normal state naturally, e.g. |
| 68 // when the window is maximized, minimized or restored. | 76 // when the window is maximized, minimized or restored. |
| 69 virtual void ResetWindowControls() = 0; | 77 virtual void ResetWindowControls(); |
| 70 | 78 |
| 71 // Prevents the non-client view from rendering as inactive when called with | 79 // Prevents the non-client view from rendering as inactive when called with |
| 72 // |disable| true, until called with false. | 80 // |disable| true, until called with false. |
| 73 void set_paint_as_active(bool paint_as_active) { | 81 void set_paint_as_active(bool paint_as_active) { |
| 74 paint_as_active_ = paint_as_active; | 82 paint_as_active_ = paint_as_active; |
| 75 } | 83 } |
| 76 | 84 |
| 85 // Get/Set client_view property. |
| 86 ClientView* client_view() const { return client_view_; } |
| 87 void set_client_view(ClientView* client_view) { |
| 88 client_view_ = client_view; |
| 89 } |
| 90 |
| 91 // NonClientView, View overrides: |
| 92 virtual gfx::Size GetPreferredSize(); |
| 93 virtual void Layout(); |
| 94 |
| 77 protected: | 95 protected: |
| 78 NonClientView() : paint_as_active_(false) {} | 96 // NonClientView, View overrides: |
| 97 virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child); |
| 79 | 98 |
| 80 // Helper for non-client view implementations to determine which area of the | 99 // Helper for non-client view implementations to determine which area of the |
| 81 // window border the specified |point| falls within. The other parameters are | 100 // window border the specified |point| falls within. The other parameters are |
| 82 // the size of the sizing edges, and whether or not the window can be | 101 // the size of the sizing edges, and whether or not the window can be |
| 83 // resized. | 102 // resized. |
| 84 int GetHTComponentForFrame(const gfx::Point& point, | 103 int GetHTComponentForFrame(const gfx::Point& point, |
| 85 int top_resize_border_height, | 104 int top_resize_border_height, |
| 86 int resize_border_thickness, | 105 int resize_border_thickness, |
| 87 int top_resize_corner_height, | 106 int top_resize_corner_height, |
| 88 int resize_corner_width, | 107 int resize_corner_width, |
| 89 bool can_resize); | 108 bool can_resize); |
| 90 | 109 |
| 91 // Accessor for paint_as_active_. | 110 // Accessor for paint_as_active_. |
| 92 bool paint_as_active() const { return paint_as_active_; } | 111 bool paint_as_active() const { return paint_as_active_; } |
| 93 | 112 |
| 94 private: | 113 private: |
| 114 // A ClientView object or subclass, responsible for sizing the contents view |
| 115 // of the window, hit testing and perhaps other tasks depending on the |
| 116 // implementation. |
| 117 ClientView* client_view_; |
| 118 |
| 95 // True when the non-client view should always be rendered as if the window | 119 // True when the non-client view should always be rendered as if the window |
| 96 // were active, regardless of whether or not the top level window actually | 120 // were active, regardless of whether or not the top level window actually |
| 97 // is active. | 121 // is active. |
| 98 bool paint_as_active_; | 122 bool paint_as_active_; |
| 99 }; | 123 }; |
| 100 | 124 |
| 101 } // namespace views | 125 } // namespace views |
| 102 | 126 |
| 103 #endif // #ifndef CHROME_VIEWS_NON_CLIENT_VIEW_H_ | 127 #endif // #ifndef CHROME_VIEWS_NON_CLIENT_VIEW_H_ |
| 104 | 128 |
| OLD | NEW |