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 #include "chrome/views/non_client_view.h" | 5 #include "chrome/views/non_client_view.h" |
6 | 6 |
7 namespace views { | 7 namespace views { |
8 | 8 |
9 const int NonClientView::kClientEdgeThickness = 1; | 9 const int NonClientView::kClientEdgeThickness = 1; |
10 | 10 |
11 int NonClientView::GetHTComponentForFrame(const gfx::Point& point, | 11 int NonClientView::GetHTComponentForFrame(const gfx::Point& point, |
12 int top_resize_border_height, | 12 int top_resize_border_height, |
13 int resize_border_thickness, | 13 int resize_border_thickness, |
14 int resize_corner_size, | 14 int top_resize_corner_height, |
| 15 int resize_corner_width, |
15 bool can_resize) { | 16 bool can_resize) { |
16 // Tricky: In XP, native behavior is to return HTTOPLEFT and HTTOPRIGHT for | 17 // Tricky: In XP, native behavior is to return HTTOPLEFT and HTTOPRIGHT for |
17 // a |resize_corner_size|-length strip of both the side and top borders, but | 18 // a |resize_corner_size|-length strip of both the side and top borders, but |
18 // only to return HTBOTTOMLEFT/HTBOTTOMRIGHT along the bottom border + corner | 19 // only to return HTBOTTOMLEFT/HTBOTTOMRIGHT along the bottom border + corner |
19 // (not the side border). Vista goes further and doesn't return these on any | 20 // (not the side border). Vista goes further and doesn't return these on any |
20 // of the side borders. Here we copy the XP behavior. | 21 // of the side borders. We allow callers to match either behavior. |
21 int component; | 22 int component; |
22 if (point.x() < resize_border_thickness) { | 23 if (point.x() < resize_border_thickness) { |
23 if (point.y() < resize_corner_size) | 24 if (point.y() < top_resize_corner_height) |
24 component = HTTOPLEFT; | 25 component = HTTOPLEFT; |
25 else if (point.y() >= (height() - resize_border_thickness)) | 26 else if (point.y() >= (height() - resize_border_thickness)) |
26 component = HTBOTTOMLEFT; | 27 component = HTBOTTOMLEFT; |
27 else | 28 else |
28 component = HTLEFT; | 29 component = HTLEFT; |
29 } else if (point.x() >= (width() - resize_border_thickness)) { | 30 } else if (point.x() >= (width() - resize_border_thickness)) { |
30 if (point.y() < resize_corner_size) | 31 if (point.y() < top_resize_corner_height) |
31 component = HTTOPRIGHT; | 32 component = HTTOPRIGHT; |
32 else if (point.y() >= (height() - resize_border_thickness)) | 33 else if (point.y() >= (height() - resize_border_thickness)) |
33 component = HTBOTTOMRIGHT; | 34 component = HTBOTTOMRIGHT; |
34 else | 35 else |
35 component = HTRIGHT; | 36 component = HTRIGHT; |
36 } else if (point.y() < top_resize_border_height) { | 37 } else if (point.y() < top_resize_border_height) { |
37 if (point.x() < resize_corner_size) | 38 if (point.x() < resize_corner_width) |
38 component = HTTOPLEFT; | 39 component = HTTOPLEFT; |
39 else if (point.x() >= (width() - resize_corner_size)) | 40 else if (point.x() >= (width() - resize_corner_width)) |
40 component = HTTOPRIGHT; | 41 component = HTTOPRIGHT; |
41 else | 42 else |
42 component = HTTOP; | 43 component = HTTOP; |
43 } else if (point.y() >= (height() - resize_border_thickness)) { | 44 } else if (point.y() >= (height() - resize_border_thickness)) { |
44 if (point.x() < resize_corner_size) | 45 if (point.x() < resize_corner_width) |
45 component = HTBOTTOMLEFT; | 46 component = HTBOTTOMLEFT; |
46 else if (point.x() >= (width() - resize_corner_size)) | 47 else if (point.x() >= (width() - resize_corner_width)) |
47 component = HTBOTTOMRIGHT; | 48 component = HTBOTTOMRIGHT; |
48 else | 49 else |
49 component = HTBOTTOM; | 50 component = HTBOTTOM; |
50 } else { | 51 } else { |
51 return HTNOWHERE; | 52 return HTNOWHERE; |
52 } | 53 } |
53 | 54 |
54 // If the window can't be resized, there are no resize boundaries, just | 55 // If the window can't be resized, there are no resize boundaries, just |
55 // window borders. | 56 // window borders. |
56 return can_resize ? component : HTBORDER; | 57 return can_resize ? component : HTBORDER; |
57 } | 58 } |
58 | 59 |
59 } // namespace views | 60 } // namespace views |
60 | 61 |
OLD | NEW |