OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 VIEWS_WINDOW_CUSTOM_FRAME_VIEW_H_ | 5 #ifndef VIEWS_WINDOW_CUSTOM_FRAME_VIEW_H_ |
6 #define VIEWS_WINDOW_CUSTOM_FRAME_VIEW_H_ | 6 #define VIEWS_WINDOW_CUSTOM_FRAME_VIEW_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "views/controls/button/image_button.h" | 9 #include "ui/views/window/custom_frame_view.h" |
10 #include "views/widget/widget.h" | 10 // TODO(tfarina): remove this file once all includes have been updated. |
11 #include "views/window/non_client_view.h" | |
12 | |
13 namespace gfx { | |
14 class Canvas; | |
15 class Font; | |
16 class Size; | |
17 class Path; | |
18 class Point; | |
19 } | |
20 | |
21 namespace views { | |
22 | |
23 /////////////////////////////////////////////////////////////////////////////// | |
24 // | |
25 // CustomFrameView | |
26 // | |
27 // A ChromeView that provides the non client frame for Windows. This means | |
28 // rendering the non-standard window caption, border, and controls. | |
29 // | |
30 //////////////////////////////////////////////////////////////////////////////// | |
31 class CustomFrameView : public NonClientFrameView, | |
32 public ButtonListener { | |
33 public: | |
34 explicit CustomFrameView(Widget* frame); | |
35 virtual ~CustomFrameView(); | |
36 | |
37 // Overridden from NonClientFrameView: | |
38 virtual gfx::Rect GetBoundsForClientView() const OVERRIDE; | |
39 virtual gfx::Rect GetWindowBoundsForClientBounds( | |
40 const gfx::Rect& client_bounds) const OVERRIDE; | |
41 virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE; | |
42 virtual void GetWindowMask(const gfx::Size& size, gfx::Path* window_mask) | |
43 OVERRIDE; | |
44 virtual void EnableClose(bool enable) OVERRIDE; | |
45 virtual void ResetWindowControls() OVERRIDE; | |
46 virtual void UpdateWindowIcon() OVERRIDE; | |
47 | |
48 // View overrides: | |
49 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | |
50 virtual void Layout() OVERRIDE; | |
51 virtual gfx::Size GetPreferredSize() OVERRIDE; | |
52 | |
53 // ButtonListener implementation: | |
54 virtual void ButtonPressed(Button* sender, const views::Event& event) | |
55 OVERRIDE; | |
56 | |
57 private: | |
58 // Returns the thickness of the border that makes up the window frame edges. | |
59 // This does not include any client edge. | |
60 int FrameBorderThickness() const; | |
61 | |
62 // Returns the thickness of the entire nonclient left, right, and bottom | |
63 // borders, including both the window frame and any client edge. | |
64 int NonClientBorderThickness() const; | |
65 | |
66 // Returns the height of the entire nonclient top border, including the window | |
67 // frame, any title area, and any connected client edge. | |
68 int NonClientTopBorderHeight() const; | |
69 | |
70 // Returns the y-coordinate of the caption buttons. | |
71 int CaptionButtonY() const; | |
72 | |
73 // Returns the thickness of the nonclient portion of the 3D edge along the | |
74 // bottom of the titlebar. | |
75 int TitlebarBottomThickness() const; | |
76 | |
77 // Returns the size of the titlebar icon. This is used even when the icon is | |
78 // not shown, e.g. to set the titlebar height. | |
79 int IconSize() const; | |
80 | |
81 // Returns the bounds of the titlebar icon (or where the icon would be if | |
82 // there was one). | |
83 gfx::Rect IconBounds() const; | |
84 | |
85 // Returns true if the client edge should be drawn. This is true if | |
86 // the window delegate wants a client edge and we are not maxmized. | |
87 bool ShouldShowClientEdge() const; | |
88 | |
89 // Paint various sub-components of this view. | |
90 void PaintRestoredFrameBorder(gfx::Canvas* canvas); | |
91 void PaintMaximizedFrameBorder(gfx::Canvas* canvas); | |
92 void PaintTitleBar(gfx::Canvas* canvas); | |
93 void PaintRestoredClientEdge(gfx::Canvas* canvas); | |
94 | |
95 // Layout various sub-components of this view. | |
96 void LayoutWindowControls(); | |
97 void LayoutTitleBar(); | |
98 void LayoutClientView(); | |
99 | |
100 // The bounds of the client view, in this view's coordinates. | |
101 gfx::Rect client_view_bounds_; | |
102 | |
103 // The layout rect of the title, if visible. | |
104 gfx::Rect title_bounds_; | |
105 | |
106 // Window controls. | |
107 ImageButton* close_button_; | |
108 ImageButton* restore_button_; | |
109 ImageButton* maximize_button_; | |
110 ImageButton* minimize_button_; | |
111 ImageButton* window_icon_; | |
112 bool should_show_minmax_buttons_; | |
113 bool should_show_client_edge_; | |
114 | |
115 // The window that owns this view. | |
116 Widget* frame_; | |
117 | |
118 // Initialize various static resources. | |
119 static void InitClass(); | |
120 static gfx::Font* title_font_; | |
121 | |
122 DISALLOW_COPY_AND_ASSIGN(CustomFrameView); | |
123 }; | |
124 | |
125 } // namespace views | |
126 | 11 |
127 #endif // VIEWS_WINDOW_CUSTOM_FRAME_VIEW_H_ | 12 #endif // VIEWS_WINDOW_CUSTOM_FRAME_VIEW_H_ |
OLD | NEW |