| 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_view_views.h" | 5 #include "ui/views/controls/table/table_view_views.h" |
| 6 | 6 |
| 7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
| 8 #include "ui/base/event.h" |
| 8 #include "ui/base/models/table_model.h" | 9 #include "ui/base/models/table_model.h" |
| 9 #include "ui/base/native_theme/native_theme.h" | 10 #include "ui/base/native_theme/native_theme.h" |
| 10 #include "ui/gfx/canvas.h" | 11 #include "ui/gfx/canvas.h" |
| 11 #include "ui/gfx/image/image_skia.h" | 12 #include "ui/gfx/image/image_skia.h" |
| 12 #include "ui/gfx/skia_util.h" | 13 #include "ui/gfx/skia_util.h" |
| 13 #include "ui/views/border.h" | 14 #include "ui/views/border.h" |
| 14 #include "ui/views/controls/scroll_view.h" | 15 #include "ui/views/controls/scroll_view.h" |
| 15 #include "ui/views/controls/table/table_view_observer.h" | 16 #include "ui/views/controls/table/table_view_observer.h" |
| 16 | 17 |
| 17 // Padding around the text (on each side). | 18 // Padding around the text (on each side). |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 width = std::max(parent()->width(), width); | 116 width = std::max(parent()->width(), width); |
| 116 height = std::max(parent()->height(), height); | 117 height = std::max(parent()->height(), height); |
| 117 } | 118 } |
| 118 SetBounds(x(), y(), width, height); | 119 SetBounds(x(), y(), width, height); |
| 119 } | 120 } |
| 120 | 121 |
| 121 gfx::Size TableView::GetPreferredSize() { | 122 gfx::Size TableView::GetPreferredSize() { |
| 122 return gfx::Size(50, RowCount() * row_height_); | 123 return gfx::Size(50, RowCount() * row_height_); |
| 123 } | 124 } |
| 124 | 125 |
| 125 bool TableView::OnKeyPressed(const KeyEvent& event) { | 126 bool TableView::OnKeyPressed(const ui::KeyEvent& event) { |
| 126 if (!HasFocus()) | 127 if (!HasFocus()) |
| 127 return false; | 128 return false; |
| 128 | 129 |
| 129 switch (event.key_code()) { | 130 switch (event.key_code()) { |
| 130 case ui::VKEY_UP: | 131 case ui::VKEY_UP: |
| 131 if (selected_row_ > 0) | 132 if (selected_row_ > 0) |
| 132 Select(selected_row_ - 1); | 133 Select(selected_row_ - 1); |
| 133 else if (selected_row_ == -1 && RowCount()) | 134 else if (selected_row_ == -1 && RowCount()) |
| 134 Select(RowCount() - 1); | 135 Select(RowCount() - 1); |
| 135 return true; | 136 return true; |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 void TableView::NumRowsChanged() { | 282 void TableView::NumRowsChanged() { |
| 282 PreferredSizeChanged(); | 283 PreferredSizeChanged(); |
| 283 SchedulePaint(); | 284 SchedulePaint(); |
| 284 } | 285 } |
| 285 | 286 |
| 286 gfx::Rect TableView::GetRowBounds(int row) { | 287 gfx::Rect TableView::GetRowBounds(int row) { |
| 287 return gfx::Rect(0, row * row_height_, width(), row_height_); | 288 return gfx::Rect(0, row * row_height_, width(), row_height_); |
| 288 } | 289 } |
| 289 | 290 |
| 290 } // namespace views | 291 } // namespace views |
| OLD | NEW |