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 #include "ui/views/controls/table/table_header.h" | 5 #include "ui/views/controls/table/table_header.h" |
6 | 6 |
7 #include "third_party/skia/include/core/SkColor.h" | 7 #include "third_party/skia/include/core/SkColor.h" |
8 #include "ui/base/cursor/cursor.h" | 8 #include "ui/base/cursor/cursor.h" |
9 #include "ui/gfx/canvas.h" | 9 #include "ui/gfx/canvas.h" |
10 #include "ui/gfx/text_utils.h" | 10 #include "ui/gfx/text_utils.h" |
11 #include "ui/native_theme/native_theme.h" | 11 #include "ui/native_theme/native_theme.h" |
12 #include "ui/views/background.h" | 12 #include "ui/views/background.h" |
13 #include "ui/views/controls/table/table_utils.h" | 13 #include "ui/views/controls/table/table_utils.h" |
14 #include "ui/views/controls/table/table_view.h" | 14 #include "ui/views/controls/table/table_view.h" |
| 15 #include "ui/views/native_cursor.h" |
15 | 16 |
16 namespace views { | 17 namespace views { |
17 | 18 |
18 namespace { | 19 namespace { |
19 | 20 |
20 const int kVerticalPadding = 4; | 21 const int kVerticalPadding = 4; |
21 | 22 |
22 // The minimum width we allow a column to go down to. | 23 // The minimum width we allow a column to go down to. |
23 const int kMinColumnWidth = 10; | 24 const int kMinColumnWidth = 10; |
24 | 25 |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 } | 158 } |
158 } | 159 } |
159 } | 160 } |
160 | 161 |
161 gfx::Size TableHeader::GetPreferredSize() { | 162 gfx::Size TableHeader::GetPreferredSize() { |
162 return gfx::Size(1, kVerticalPadding * 2 + font_list_.GetHeight()); | 163 return gfx::Size(1, kVerticalPadding * 2 + font_list_.GetHeight()); |
163 } | 164 } |
164 | 165 |
165 gfx::NativeCursor TableHeader::GetCursor(const ui::MouseEvent& event) { | 166 gfx::NativeCursor TableHeader::GetCursor(const ui::MouseEvent& event) { |
166 return GetResizeColumn(GetMirroredXInView(event.x())) != -1 ? | 167 return GetResizeColumn(GetMirroredXInView(event.x())) != -1 ? |
167 ui::kCursorColumnResize : View::GetCursor(event); | 168 GetNativeColumnResizeCursor() : View::GetCursor(event); |
168 } | 169 } |
169 | 170 |
170 bool TableHeader::OnMousePressed(const ui::MouseEvent& event) { | 171 bool TableHeader::OnMousePressed(const ui::MouseEvent& event) { |
171 if (event.IsOnlyLeftMouseButton()) { | 172 if (event.IsOnlyLeftMouseButton()) { |
172 StartResize(event); | 173 StartResize(event); |
173 return true; | 174 return true; |
174 } | 175 } |
175 | 176 |
176 // Return false so that context menus on ancestors work. | 177 // Return false so that context menus on ancestors work. |
177 return false; | 178 return false; |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 if (index > 0 && x >= column.x - kResizePadding && | 269 if (index > 0 && x >= column.x - kResizePadding && |
269 x <= column.x + kResizePadding) { | 270 x <= column.x + kResizePadding) { |
270 return index - 1; | 271 return index - 1; |
271 } | 272 } |
272 const int max_x = column.x + column.width; | 273 const int max_x = column.x + column.width; |
273 return (x >= max_x - kResizePadding && x <= max_x + kResizePadding) ? | 274 return (x >= max_x - kResizePadding && x <= max_x + kResizePadding) ? |
274 index : -1; | 275 index : -1; |
275 } | 276 } |
276 | 277 |
277 } // namespace views | 278 } // namespace views |
OLD | NEW |