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.h" | 5 #include "ui/views/controls/table/table_view.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 if (row < 0 || row >= RowCount()) | 397 if (row < 0 || row >= RowCount()) |
398 return; | 398 return; |
399 | 399 |
400 event->StopPropagation(); | 400 event->StopPropagation(); |
401 ui::ListSelectionModel new_model; | 401 ui::ListSelectionModel new_model; |
402 ConfigureSelectionModelForEvent(*event, &new_model); | 402 ConfigureSelectionModelForEvent(*event, &new_model); |
403 SetSelectionModel(new_model); | 403 SetSelectionModel(new_model); |
404 } | 404 } |
405 | 405 |
406 bool TableView::GetTooltipText(const gfx::Point& p, | 406 bool TableView::GetTooltipText(const gfx::Point& p, |
407 string16* tooltip) const { | 407 base::string16* tooltip) const { |
408 return GetTooltipImpl(p, tooltip, NULL); | 408 return GetTooltipImpl(p, tooltip, NULL); |
409 } | 409 } |
410 | 410 |
411 bool TableView::GetTooltipTextOrigin(const gfx::Point& p, | 411 bool TableView::GetTooltipTextOrigin(const gfx::Point& p, |
412 gfx::Point* loc) const { | 412 gfx::Point* loc) const { |
413 return GetTooltipImpl(p, NULL, loc); | 413 return GetTooltipImpl(p, NULL, loc); |
414 } | 414 } |
415 | 415 |
416 void TableView::OnModelChanged() { | 416 void TableView::OnModelChanged() { |
417 selection_model_.Clear(); | 417 selection_model_.Clear(); |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
864 if (grouper_) { | 864 if (grouper_) { |
865 grouper_->GetGroupRange(model_index, &range); | 865 grouper_->GetGroupRange(model_index, &range); |
866 } else { | 866 } else { |
867 range.start = model_index; | 867 range.start = model_index; |
868 range.length = 1; | 868 range.length = 1; |
869 } | 869 } |
870 return range; | 870 return range; |
871 } | 871 } |
872 | 872 |
873 bool TableView::GetTooltipImpl(const gfx::Point& location, | 873 bool TableView::GetTooltipImpl(const gfx::Point& location, |
874 string16* tooltip, | 874 base::string16* tooltip, |
875 gfx::Point* tooltip_origin) const { | 875 gfx::Point* tooltip_origin) const { |
876 const int row = location.y() / row_height_; | 876 const int row = location.y() / row_height_; |
877 if (row < 0 || row >= RowCount() || visible_columns_.empty()) | 877 if (row < 0 || row >= RowCount() || visible_columns_.empty()) |
878 return false; | 878 return false; |
879 | 879 |
880 const int x = GetMirroredXInView(location.x()); | 880 const int x = GetMirroredXInView(location.x()); |
881 const int column = GetClosestVisibleColumnIndex(this, x); | 881 const int column = GetClosestVisibleColumnIndex(this, x); |
882 if (x < visible_columns_[column].x || | 882 if (x < visible_columns_[column].x || |
883 x > (visible_columns_[column].x + visible_columns_[column].width)) | 883 x > (visible_columns_[column].x + visible_columns_[column].width)) |
884 return false; | 884 return false; |
885 | 885 |
886 const string16 text(model_->GetText(ViewToModel(row), | 886 const base::string16 text(model_->GetText(ViewToModel(row), |
887 visible_columns_[column].column.id)); | 887 visible_columns_[column].column.id)); |
888 if (text.empty()) | 888 if (text.empty()) |
889 return false; | 889 return false; |
890 | 890 |
891 gfx::Rect cell_bounds(GetCellBounds(row, column)); | 891 gfx::Rect cell_bounds(GetCellBounds(row, column)); |
892 AdjustCellBoundsForText(column, &cell_bounds); | 892 AdjustCellBoundsForText(column, &cell_bounds); |
893 const int right = std::min(GetVisibleBounds().right(), cell_bounds.right()); | 893 const int right = std::min(GetVisibleBounds().right(), cell_bounds.right()); |
894 if (right > cell_bounds.x() && | 894 if (right > cell_bounds.x() && |
895 font_.GetStringWidth(text) <= (right - cell_bounds.x())) | 895 font_.GetStringWidth(text) <= (right - cell_bounds.x())) |
896 return false; | 896 return false; |
897 | 897 |
898 if (tooltip) | 898 if (tooltip) |
899 *tooltip = text; | 899 *tooltip = text; |
900 if (tooltip_origin) { | 900 if (tooltip_origin) { |
901 tooltip_origin->SetPoint(cell_bounds.x(), | 901 tooltip_origin->SetPoint(cell_bounds.x(), |
902 cell_bounds.y() + kTextVerticalPadding); | 902 cell_bounds.y() + kTextVerticalPadding); |
903 } | 903 } |
904 return true; | 904 return true; |
905 } | 905 } |
906 | 906 |
907 } // namespace views | 907 } // namespace views |
OLD | NEW |