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 #include "views/controls/resize_area.h" | 5 #include "views/controls/resize_area.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "ui/base/accessibility/accessible_view_state.h" | 8 #include "ui/base/accessibility/accessible_view_state.h" |
9 #include "ui/base/resource/resource_bundle.h" | 9 #include "ui/base/resource/resource_bundle.h" |
10 | 10 |
11 #if defined(OS_LINUX) | 11 #if defined(OS_LINUX) |
12 #include "ui/gfx/gtk_util.h" | 12 #include "ui/gfx/gtk_util.h" |
13 #endif | 13 #endif |
14 | 14 |
15 namespace views { | 15 namespace views { |
16 | 16 |
17 const char ResizeArea::kViewClassName[] = "views/ResizeArea"; | 17 const char ResizeArea::kViewClassName[] = "views/ResizeArea"; |
18 | 18 |
19 #if defined(OS_WIN) | |
20 static HCURSOR g_resize_cursor = NULL; | |
21 #endif | |
22 | |
23 //////////////////////////////////////////////////////////////////////////////// | 19 //////////////////////////////////////////////////////////////////////////////// |
24 // ResizeArea | 20 // ResizeArea |
25 | 21 |
26 ResizeArea::ResizeArea(ResizeAreaDelegate* delegate) | 22 ResizeArea::ResizeArea(ResizeAreaDelegate* delegate) |
27 : delegate_(delegate), | 23 : delegate_(delegate), |
28 initial_position_(0) { | 24 initial_position_(0) { |
29 } | 25 } |
30 | 26 |
31 ResizeArea::~ResizeArea() { | 27 ResizeArea::~ResizeArea() { |
32 } | 28 } |
33 | 29 |
34 std::string ResizeArea::GetClassName() const { | 30 std::string ResizeArea::GetClassName() const { |
35 return kViewClassName; | 31 return kViewClassName; |
36 } | 32 } |
37 | 33 |
38 gfx::NativeCursor ResizeArea::GetCursorForPoint(ui::EventType event_type, | 34 gfx::NativeCursor ResizeArea::GetCursorForPoint(ui::EventType event_type, |
39 const gfx::Point& p) { | 35 const gfx::Point& p) { |
40 if (!enabled_) | 36 if (!enabled_) |
41 return NULL; | 37 return NULL; |
42 #if defined(OS_WIN) | 38 #if defined(OS_WIN) |
43 if (!g_resize_cursor) | 39 static HCURSOR g_resize_cursor = LoadCursor(NULL, IDC_SIZEWE); |
44 g_resize_cursor = LoadCursor(NULL, IDC_SIZEWE); | |
45 return g_resize_cursor; | 40 return g_resize_cursor; |
46 #elif defined(OS_LINUX) | 41 #elif defined(OS_LINUX) |
47 return gfx::GetCursor(GDK_SB_H_DOUBLE_ARROW); | 42 return gfx::GetCursor(GDK_SB_H_DOUBLE_ARROW); |
48 #endif | 43 #endif |
49 } | 44 } |
50 | 45 |
51 bool ResizeArea::OnMousePressed(const views::MouseEvent& event) { | 46 bool ResizeArea::OnMousePressed(const views::MouseEvent& event) { |
52 if (!event.IsOnlyLeftMouseButton()) | 47 if (!event.IsOnlyLeftMouseButton()) |
53 return false; | 48 return false; |
54 | 49 |
(...skipping 29 matching lines...) Expand all Loading... |
84 | 79 |
85 void ResizeArea::ReportResizeAmount(int resize_amount, bool last_update) { | 80 void ResizeArea::ReportResizeAmount(int resize_amount, bool last_update) { |
86 gfx::Point point(resize_amount, 0); | 81 gfx::Point point(resize_amount, 0); |
87 View::ConvertPointToScreen(this, &point); | 82 View::ConvertPointToScreen(this, &point); |
88 resize_amount = point.x() - initial_position_; | 83 resize_amount = point.x() - initial_position_; |
89 delegate_->OnResize(base::i18n::IsRTL() ? -resize_amount : resize_amount, | 84 delegate_->OnResize(base::i18n::IsRTL() ? -resize_amount : resize_amount, |
90 last_update); | 85 last_update); |
91 } | 86 } |
92 | 87 |
93 } // namespace views | 88 } // namespace views |
OLD | NEW |