| 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 "third_party/skia/include/core/SkBitmap.h" | |
| 9 #include "ui/base/models/table_model.h" | 8 #include "ui/base/models/table_model.h" |
| 9 #include "ui/base/native_theme/native_theme.h" |
| 10 #include "ui/gfx/canvas.h" | 10 #include "ui/gfx/canvas.h" |
| 11 #include "ui/base/native_theme/native_theme.h" | 11 #include "ui/gfx/image/image_skia.h" |
| 12 #include "ui/gfx/skia_util.h" | 12 #include "ui/gfx/skia_util.h" |
| 13 #include "ui/views/border.h" | 13 #include "ui/views/border.h" |
| 14 #include "ui/views/controls/scroll_view.h" | 14 #include "ui/views/controls/scroll_view.h" |
| 15 #include "ui/views/controls/table/table_view_observer.h" | 15 #include "ui/views/controls/table/table_view_observer.h" |
| 16 | 16 |
| 17 // Padding around the text (on each side). | 17 // Padding around the text (on each side). |
| 18 static const int kTextVerticalPadding = 3; | 18 static const int kTextVerticalPadding = 3; |
| 19 static const int kTextHorizontalPadding = 2; | 19 static const int kTextHorizontalPadding = 2; |
| 20 | 20 |
| 21 // TODO: these should come from native theme or something. | 21 // TODO: these should come from native theme or something. |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 max_row = std::min(max_row, RowCount()); | 242 max_row = std::min(max_row, RowCount()); |
| 243 for (int i = min_row; i < max_row; ++i) { | 243 for (int i = min_row; i < max_row; ++i) { |
| 244 gfx::Rect row_bounds(GetRowBounds(i)); | 244 gfx::Rect row_bounds(GetRowBounds(i)); |
| 245 if (i == selected_row_) { | 245 if (i == selected_row_) { |
| 246 canvas->FillRect(row_bounds, kSelectedBackgroundColor); | 246 canvas->FillRect(row_bounds, kSelectedBackgroundColor); |
| 247 if (HasFocus()) | 247 if (HasFocus()) |
| 248 canvas->DrawFocusRect(row_bounds); | 248 canvas->DrawFocusRect(row_bounds); |
| 249 } | 249 } |
| 250 int text_x = kTextHorizontalPadding; | 250 int text_x = kTextHorizontalPadding; |
| 251 if (table_type_ == ICON_AND_TEXT) { | 251 if (table_type_ == ICON_AND_TEXT) { |
| 252 SkBitmap image = model_->GetIcon(i); | 252 gfx::ImageSkia image = model_->GetIcon(i); |
| 253 if (!image.isNull()) { | 253 if (!image.isNull()) { |
| 254 int image_x = GetMirroredXWithWidthInView(text_x, image.width()); | 254 int image_x = GetMirroredXWithWidthInView(text_x, image.width()); |
| 255 canvas->DrawBitmapInt( | 255 canvas->DrawBitmapInt( |
| 256 image, 0, 0, image.width(), image.height(), | 256 image, 0, 0, image.width(), image.height(), |
| 257 image_x, row_bounds.y() + (row_bounds.height() - kImageSize) / 2, | 257 image_x, row_bounds.y() + (row_bounds.height() - kImageSize) / 2, |
| 258 kImageSize, kImageSize, true); | 258 kImageSize, kImageSize, true); |
| 259 } | 259 } |
| 260 text_x += kImageSize + kImageToTextPadding; | 260 text_x += kImageSize + kImageToTextPadding; |
| 261 } | 261 } |
| 262 canvas->DrawStringInt( | 262 canvas->DrawStringInt( |
| (...skipping 18 matching lines...) Expand all Loading... |
| 281 void TableView::NumRowsChanged() { | 281 void TableView::NumRowsChanged() { |
| 282 PreferredSizeChanged(); | 282 PreferredSizeChanged(); |
| 283 SchedulePaint(); | 283 SchedulePaint(); |
| 284 } | 284 } |
| 285 | 285 |
| 286 gfx::Rect TableView::GetRowBounds(int row) { | 286 gfx::Rect TableView::GetRowBounds(int row) { |
| 287 return gfx::Rect(0, row * row_height_, width(), row_height_); | 287 return gfx::Rect(0, row * row_height_, width(), row_height_); |
| 288 } | 288 } |
| 289 | 289 |
| 290 } // namespace views | 290 } // namespace views |
| OLD | NEW |