| 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/combobox/native_combobox_views.h" | 5 #include "views/controls/combobox/native_combobox_views.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 path.lineTo(SkIntToScalar(tip_x - shift_x), SkIntToScalar(tip_y + shift_y)); | 295 path.lineTo(SkIntToScalar(tip_x - shift_x), SkIntToScalar(tip_y + shift_y)); |
| 296 path.close(); | 296 path.close(); |
| 297 canvas->GetSkCanvas()->drawPath(path, paint); | 297 canvas->GetSkCanvas()->drawPath(path, paint); |
| 298 } | 298 } |
| 299 | 299 |
| 300 | 300 |
| 301 void NativeComboboxViews::PaintText(gfx::Canvas* canvas) { | 301 void NativeComboboxViews::PaintText(gfx::Canvas* canvas) { |
| 302 gfx::Insets insets = GetInsets(); | 302 gfx::Insets insets = GetInsets(); |
| 303 | 303 |
| 304 canvas->Save(); | 304 canvas->Save(); |
| 305 canvas->ClipRectInt(insets.left(), insets.top(), | 305 canvas->ClipRectInt(GetContentsBounds()); |
| 306 width() - insets.width(), height() - insets.height()); | |
| 307 | 306 |
| 308 int x = insets.left(); | 307 int x = insets.left(); |
| 309 int y = insets.top(); | 308 int y = insets.top(); |
| 310 int text_height = height() - insets.height(); | 309 int text_height = height() - insets.height(); |
| 311 SkColor text_color = kTextColor; | 310 SkColor text_color = kTextColor; |
| 312 | 311 |
| 313 int index = GetSelectedItem(); | 312 int index = GetSelectedItem(); |
| 314 if (index < 0 || index > combobox_->model()->GetItemCount()) | 313 if (index < 0 || index > combobox_->model()->GetItemCount()) |
| 315 index = 0; | 314 index = 0; |
| 316 string16 text = combobox_->model()->GetItemAt(index); | 315 string16 text = combobox_->model()->GetItemAt(index); |
| 317 | 316 |
| 318 const gfx::Font &font = GetFont(); | 317 const gfx::Font& font = GetFont(); |
| 319 int width = font.GetStringWidth(text); | 318 int width = font.GetStringWidth(text); |
| 320 | 319 |
| 321 canvas->DrawStringInt(text, font, text_color, x, y, width, text_height); | 320 canvas->DrawStringInt(text, font, text_color, x, y, width, text_height); |
| 322 | 321 |
| 323 // draw the double arrow | 322 // draw the double arrow |
| 324 gfx::Rect lb = GetLocalBounds(); | 323 gfx::Rect lb = GetLocalBounds(); |
| 325 DrawArrow(canvas, | 324 DrawArrow(canvas, |
| 326 lb.width() - (kComboboxArrowSize / 2) - kComboboxArrowOffset, | 325 lb.width() - (kComboboxArrowSize / 2) - kComboboxArrowOffset, |
| 327 lb.height() / 2 - kComboboxArrowSize, | 326 lb.height() / 2 - kComboboxArrowSize, |
| 328 kComboboxArrowSize / 2, | 327 kComboboxArrowSize / 2, |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 | 377 |
| 379 #if defined(USE_AURA) | 378 #if defined(USE_AURA) |
| 380 // static | 379 // static |
| 381 NativeComboboxWrapper* NativeComboboxWrapper::CreateWrapper( | 380 NativeComboboxWrapper* NativeComboboxWrapper::CreateWrapper( |
| 382 Combobox* combobox) { | 381 Combobox* combobox) { |
| 383 return new NativeComboboxViews(combobox); | 382 return new NativeComboboxViews(combobox); |
| 384 } | 383 } |
| 385 #endif | 384 #endif |
| 386 | 385 |
| 387 } // namespace views | 386 } // namespace views |
| OLD | NEW |