| 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 UI_VIEWS_WINDOW_CUSTOM_FRAME_VIEW_H_ | 5 #ifndef UI_VIEWS_WINDOW_CUSTOM_FRAME_VIEW_H_ |
| 6 #define UI_VIEWS_WINDOW_CUSTOM_FRAME_VIEW_H_ | 6 #define UI_VIEWS_WINDOW_CUSTOM_FRAME_VIEW_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "ui/views/controls/button/button.h" | 11 #include "ui/views/controls/button/button.h" |
| 12 #include "ui/views/window/frame_buttons.h" | |
| 13 #include "ui/views/window/non_client_view.h" | 12 #include "ui/views/window/non_client_view.h" |
| 14 | 13 |
| 15 namespace gfx { | 14 namespace gfx { |
| 16 class ImageSkia; | 15 class ImageSkia; |
| 17 } | 16 } |
| 18 | 17 |
| 19 namespace views { | 18 namespace views { |
| 20 | 19 |
| 21 class FrameBackground; | 20 class FrameBackground; |
| 22 class ImageButton; | 21 class ImageButton; |
| 23 class Widget; | 22 class Widget; |
| 24 | 23 |
| 25 /////////////////////////////////////////////////////////////////////////////// | 24 /////////////////////////////////////////////////////////////////////////////// |
| 26 // | 25 // |
| 27 // CustomFrameView | 26 // CustomFrameView |
| 28 // | 27 // |
| 29 // A view that provides the non client frame for Windows. This means | 28 // A view that provides the non client frame for Windows. This means |
| 30 // rendering the non-standard window caption, border, and controls. | 29 // rendering the non-standard window caption, border, and controls. |
| 31 // | 30 // |
| 32 //////////////////////////////////////////////////////////////////////////////// | 31 //////////////////////////////////////////////////////////////////////////////// |
| 33 class VIEWS_EXPORT CustomFrameView : public NonClientFrameView, | 32 class CustomFrameView : public NonClientFrameView, |
| 34 public ButtonListener { | 33 public ButtonListener { |
| 35 public: | 34 public: |
| 36 CustomFrameView(); | 35 CustomFrameView(); |
| 37 virtual ~CustomFrameView(); | 36 virtual ~CustomFrameView(); |
| 38 | 37 |
| 39 void Init(Widget* frame); | 38 void Init(Widget* frame); |
| 40 | 39 |
| 41 // Overridden from NonClientFrameView: | 40 // Overridden from NonClientFrameView: |
| 42 virtual gfx::Rect GetBoundsForClientView() const OVERRIDE; | 41 virtual gfx::Rect GetBoundsForClientView() const OVERRIDE; |
| 43 virtual gfx::Rect GetWindowBoundsForClientBounds( | 42 virtual gfx::Rect GetWindowBoundsForClientBounds( |
| 44 const gfx::Rect& client_bounds) const OVERRIDE; | 43 const gfx::Rect& client_bounds) const OVERRIDE; |
| 45 virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE; | 44 virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE; |
| 46 virtual void GetWindowMask(const gfx::Size& size, | 45 virtual void GetWindowMask(const gfx::Size& size, |
| 47 gfx::Path* window_mask) OVERRIDE; | 46 gfx::Path* window_mask) OVERRIDE; |
| 48 virtual void ResetWindowControls() OVERRIDE; | 47 virtual void ResetWindowControls() OVERRIDE; |
| 49 virtual void UpdateWindowIcon() OVERRIDE; | 48 virtual void UpdateWindowIcon() OVERRIDE; |
| 50 virtual void UpdateWindowTitle() OVERRIDE; | 49 virtual void UpdateWindowTitle() OVERRIDE; |
| 51 | 50 |
| 52 // Overridden from View: | 51 // Overridden from View: |
| 53 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 52 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
| 54 virtual void Layout() OVERRIDE; | 53 virtual void Layout() OVERRIDE; |
| 55 virtual gfx::Size GetPreferredSize() OVERRIDE; | 54 virtual gfx::Size GetPreferredSize() OVERRIDE; |
| 56 virtual gfx::Size GetMinimumSize() OVERRIDE; | 55 virtual gfx::Size GetMinimumSize() OVERRIDE; |
| 57 virtual gfx::Size GetMaximumSize() OVERRIDE; | 56 virtual gfx::Size GetMaximumSize() OVERRIDE; |
| 58 | 57 |
| 59 // Overridden from ButtonListener: | 58 // Overridden from ButtonListener: |
| 60 virtual void ButtonPressed(Button* sender, const ui::Event& event) OVERRIDE; | 59 virtual void ButtonPressed(Button* sender, const ui::Event& event) OVERRIDE; |
| 61 | 60 |
| 62 private: | 61 private: |
| 63 friend class CustomFrameViewTest; | |
| 64 | |
| 65 // Returns the thickness of the border that makes up the window frame edges. | 62 // Returns the thickness of the border that makes up the window frame edges. |
| 66 // This does not include any client edge. | 63 // This does not include any client edge. |
| 67 int FrameBorderThickness() const; | 64 int FrameBorderThickness() const; |
| 68 | 65 |
| 69 // Returns the thickness of the entire nonclient left, right, and bottom | 66 // Returns the thickness of the entire nonclient left, right, and bottom |
| 70 // borders, including both the window frame and any client edge. | 67 // borders, including both the window frame and any client edge. |
| 71 int NonClientBorderThickness() const; | 68 int NonClientBorderThickness() const; |
| 72 | 69 |
| 73 // Returns the height of the entire nonclient top border, including the window | 70 // Returns the height of the entire nonclient top border, including the window |
| 74 // frame, any title area, and any connected client edge. | 71 // frame, any title area, and any connected client edge. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 100 // Paint various sub-components of this view. | 97 // Paint various sub-components of this view. |
| 101 void PaintRestoredFrameBorder(gfx::Canvas* canvas); | 98 void PaintRestoredFrameBorder(gfx::Canvas* canvas); |
| 102 void PaintMaximizedFrameBorder(gfx::Canvas* canvas); | 99 void PaintMaximizedFrameBorder(gfx::Canvas* canvas); |
| 103 void PaintTitleBar(gfx::Canvas* canvas); | 100 void PaintTitleBar(gfx::Canvas* canvas); |
| 104 void PaintRestoredClientEdge(gfx::Canvas* canvas); | 101 void PaintRestoredClientEdge(gfx::Canvas* canvas); |
| 105 | 102 |
| 106 // Compute aspects of the frame needed to paint the frame background. | 103 // Compute aspects of the frame needed to paint the frame background. |
| 107 SkColor GetFrameColor() const; | 104 SkColor GetFrameColor() const; |
| 108 const gfx::ImageSkia* GetFrameImage() const; | 105 const gfx::ImageSkia* GetFrameImage() const; |
| 109 | 106 |
| 110 // Performs the layout for the window control buttons based on the | 107 // Layout various sub-components of this view. |
| 111 // configuration specified in |leading_buttons_| and |trailing_buttons_|. | |
| 112 // The sizing and positions of the buttons affects LayoutTitleBar, call | |
| 113 // this beforehand. | |
| 114 void LayoutWindowControls(); | 108 void LayoutWindowControls(); |
| 115 | |
| 116 // Calculations depend on the positions of the window controls. Always call | |
| 117 // LayoutWindowControls beforehand. | |
| 118 void LayoutTitleBar(); | 109 void LayoutTitleBar(); |
| 119 void LayoutClientView(); | 110 void LayoutClientView(); |
| 120 | 111 |
| 121 // Creates, adds and returns a new window caption button (e.g, minimize, | 112 // Creates, adds and returns a new window caption button (e.g, minimize, |
| 122 // maximize, restore). | 113 // maximize, restore). |
| 123 ImageButton* InitWindowCaptionButton(int accessibility_string_id, | 114 ImageButton* InitWindowCaptionButton(int accessibility_string_id, |
| 124 int normal_image_id, | 115 int normal_image_id, |
| 125 int hot_image_id, | 116 int hot_image_id, |
| 126 int pushed_image_id); | 117 int pushed_image_id); |
| 127 | 118 |
| 128 // Returns the window caption button for the given FrameButton type, if it | |
| 129 // should be visible. Otherwise NULL. | |
| 130 ImageButton* GetImageButton(views::FrameButton button); | |
| 131 | |
| 132 // The bounds of the client view, in this view's coordinates. | 119 // The bounds of the client view, in this view's coordinates. |
| 133 gfx::Rect client_view_bounds_; | 120 gfx::Rect client_view_bounds_; |
| 134 | 121 |
| 135 // The layout rect of the title, if visible. | 122 // The layout rect of the title, if visible. |
| 136 gfx::Rect title_bounds_; | 123 gfx::Rect title_bounds_; |
| 137 | 124 |
| 138 // Not owned. | 125 // Not owned. |
| 139 Widget* frame_; | 126 Widget* frame_; |
| 140 | 127 |
| 141 // The icon of this window. May be NULL. | 128 // The icon of this window. May be NULL. |
| 142 ImageButton* window_icon_; | 129 ImageButton* window_icon_; |
| 143 | 130 |
| 144 // Window caption buttons. | 131 // Window caption buttons. |
| 145 ImageButton* minimize_button_; | 132 ImageButton* minimize_button_; |
| 146 ImageButton* maximize_button_; | 133 ImageButton* maximize_button_; |
| 147 ImageButton* restore_button_; | 134 ImageButton* restore_button_; |
| 148 ImageButton* close_button_; | 135 ImageButton* close_button_; |
| 149 | 136 |
| 150 // Should maximize button be shown? | 137 // Should maximize button be shown? |
| 151 bool should_show_maximize_button_; | 138 bool should_show_maximize_button_; |
| 152 | 139 |
| 153 // Background painter for the window frame. | 140 // Background painter for the window frame. |
| 154 scoped_ptr<FrameBackground> frame_background_; | 141 scoped_ptr<FrameBackground> frame_background_; |
| 155 | 142 |
| 156 // The horizontal boundaries for the title bar to layout within. Restricted | |
| 157 // by the space used by the leading and trailing buttons. | |
| 158 int minimum_title_bar_x_; | |
| 159 int maximum_title_bar_x_; | |
| 160 | |
| 161 DISALLOW_COPY_AND_ASSIGN(CustomFrameView); | 143 DISALLOW_COPY_AND_ASSIGN(CustomFrameView); |
| 162 }; | 144 }; |
| 163 | 145 |
| 164 } // namespace views | 146 } // namespace views |
| 165 | 147 |
| 166 #endif // UI_VIEWS_WINDOW_CUSTOM_FRAME_VIEW_H_ | 148 #endif // UI_VIEWS_WINDOW_CUSTOM_FRAME_VIEW_H_ |
| OLD | NEW |