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/combobox/native_combobox_views.h" | 5 #include "ui/views/controls/combobox/native_combobox_views.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "grit/ui_resources.h" | 9 #include "grit/ui_resources.h" |
10 #include "ui/base/events/event.h" | 10 #include "ui/base/events/event.h" |
11 #include "ui/base/keycodes/keyboard_codes.h" | 11 #include "ui/base/keycodes/keyboard_codes.h" |
12 #include "ui/base/models/combobox_model.h" | 12 #include "ui/base/models/combobox_model.h" |
13 #include "ui/base/resource/resource_bundle.h" | 13 #include "ui/base/resource/resource_bundle.h" |
14 #include "ui/gfx/canvas.h" | 14 #include "ui/gfx/canvas.h" |
15 #include "ui/gfx/font.h" | 15 #include "ui/gfx/font.h" |
16 #include "ui/gfx/image/image.h" | 16 #include "ui/gfx/image/image.h" |
17 #include "ui/gfx/path.h" | 17 #include "ui/gfx/path.h" |
18 #include "ui/native_theme/native_theme.h" | |
18 #include "ui/views/background.h" | 19 #include "ui/views/background.h" |
19 #include "ui/views/border.h" | 20 #include "ui/views/border.h" |
20 #include "ui/views/controls/combobox/combobox.h" | 21 #include "ui/views/controls/combobox/combobox.h" |
21 #include "ui/views/controls/focusable_border.h" | 22 #include "ui/views/controls/focusable_border.h" |
22 #include "ui/views/controls/menu/menu_runner.h" | 23 #include "ui/views/controls/menu/menu_runner.h" |
23 #include "ui/views/controls/menu/submenu_view.h" | 24 #include "ui/views/controls/menu/submenu_view.h" |
24 #include "ui/views/widget/root_view.h" | 25 #include "ui/views/widget/root_view.h" |
25 #include "ui/views/widget/widget.h" | 26 #include "ui/views/widget/widget.h" |
26 | 27 |
27 namespace views { | 28 namespace views { |
(...skipping 12 matching lines...) Expand all Loading... | |
40 const int kMenuBorderWidthRight = 1; | 41 const int kMenuBorderWidthRight = 1; |
41 const int kMenuBorderWidthBottom = 2; | 42 const int kMenuBorderWidthBottom = 2; |
42 | 43 |
43 // Limit how small a combobox can be. | 44 // Limit how small a combobox can be. |
44 const int kMinComboboxWidth = 148; | 45 const int kMinComboboxWidth = 148; |
45 | 46 |
46 // Size of the combobox arrow margins | 47 // Size of the combobox arrow margins |
47 const int kDisclosureArrowLeftPadding = 7; | 48 const int kDisclosureArrowLeftPadding = 7; |
48 const int kDisclosureArrowRightPadding = 7; | 49 const int kDisclosureArrowRightPadding = 7; |
49 | 50 |
50 // Color settings for text and border. | |
51 // These are tentative, and should be derived from theme, system | |
52 // settings and current settings. | |
53 const SkColor kTextColor = SK_ColorBLACK; | |
54 const SkColor kInvalidTextColor = SK_ColorWHITE; | |
55 | |
56 // Define the id of the first item in the menu (since it needs to be > 0) | 51 // Define the id of the first item in the menu (since it needs to be > 0) |
57 const int kFirstMenuItemId = 1000; | 52 const int kFirstMenuItemId = 1000; |
58 | 53 |
59 // The background to use for invalid comboboxes. | 54 // The background to use for invalid comboboxes. |
60 class InvalidBackground : public Background { | 55 class InvalidBackground : public Background { |
61 public: | 56 public: |
62 InvalidBackground() {} | 57 InvalidBackground() {} |
63 virtual ~InvalidBackground() {} | 58 virtual ~InvalidBackground() {} |
64 | 59 |
65 // Overridden from Background: | 60 // Overridden from Background: |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
321 | 316 |
322 void NativeComboboxViews::PaintText(gfx::Canvas* canvas) { | 317 void NativeComboboxViews::PaintText(gfx::Canvas* canvas) { |
323 gfx::Insets insets = GetInsets(); | 318 gfx::Insets insets = GetInsets(); |
324 | 319 |
325 canvas->Save(); | 320 canvas->Save(); |
326 canvas->ClipRect(GetContentsBounds()); | 321 canvas->ClipRect(GetContentsBounds()); |
327 | 322 |
328 int x = insets.left(); | 323 int x = insets.left(); |
329 int y = insets.top(); | 324 int y = insets.top(); |
330 int text_height = height() - insets.height(); | 325 int text_height = height() - insets.height(); |
331 SkColor text_color = combobox_->invalid() ? kInvalidTextColor : kTextColor; | 326 SkColor text_color = GetNativeTheme()->GetSystemColor( |
327 combobox_->invalid() ? ui::NativeTheme::kColorId_LabelDisabledColor : | |
Evan Stade
2013/05/01 23:18:50
this broke the code. For my desktop chromeos build
Elliot Glaysher
2013/05/01 23:23:20
Desktop chromeos shouldn't be using NativeThemeGtk
Evan Stade
2013/05/01 23:28:45
no. LabelDisabledColor is just not the right color
| |
328 ui::NativeTheme::kColorId_LabelEnabledColor); | |
332 | 329 |
333 int index = GetSelectedIndex(); | 330 int index = GetSelectedIndex(); |
334 if (index < 0 || index > combobox_->model()->GetItemCount()) | 331 if (index < 0 || index > combobox_->model()->GetItemCount()) |
335 index = 0; | 332 index = 0; |
336 string16 text = combobox_->model()->GetItemAt(index); | 333 string16 text = combobox_->model()->GetItemAt(index); |
337 | 334 |
338 int disclosure_arrow_offset = width() - disclosure_arrow_->width() | 335 int disclosure_arrow_offset = width() - disclosure_arrow_->width() |
339 - kDisclosureArrowLeftPadding - kDisclosureArrowRightPadding; | 336 - kDisclosureArrowLeftPadding - kDisclosureArrowRightPadding; |
340 | 337 |
341 const gfx::Font& font = Combobox::GetFont(); | 338 const gfx::Font& font = Combobox::GetFont(); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
407 | 404 |
408 #if defined(USE_AURA) | 405 #if defined(USE_AURA) |
409 // static | 406 // static |
410 NativeComboboxWrapper* NativeComboboxWrapper::CreateWrapper( | 407 NativeComboboxWrapper* NativeComboboxWrapper::CreateWrapper( |
411 Combobox* combobox) { | 408 Combobox* combobox) { |
412 return new NativeComboboxViews(combobox); | 409 return new NativeComboboxViews(combobox); |
413 } | 410 } |
414 #endif | 411 #endif |
415 | 412 |
416 } // namespace views | 413 } // namespace views |
OLD | NEW |