Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(251)

Side by Side Diff: ui/views/controls/combobox/native_combobox_views.cc

Issue 9839034: views: Refactor the way we get the combo box font. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "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 30 matching lines...) Expand all
41 const int kDisclosureArrowRightPadding = 7; 41 const int kDisclosureArrowRightPadding = 7;
42 42
43 // Color settings for text and border. 43 // Color settings for text and border.
44 // These are tentative, and should be derived from theme, system 44 // These are tentative, and should be derived from theme, system
45 // settings and current settings. 45 // settings and current settings.
46 const SkColor kTextColor = SK_ColorBLACK; 46 const SkColor kTextColor = SK_ColorBLACK;
47 47
48 // Define the id of the first item in the menu (since it needs to be > 0) 48 // Define the id of the first item in the menu (since it needs to be > 0)
49 const int kFirstMenuItemId = 1000; 49 const int kFirstMenuItemId = 1000;
50 50
51 const gfx::Font& GetFont() {
sky 2012/03/23 15:36:38 Maybe we should promote this to combobox so that b
52 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
53 return rb.GetFont(ui::ResourceBundle::BaseFont);
54 }
55
51 } // namespace 56 } // namespace
52 57
53 namespace views { 58 namespace views {
54 59
55 const char NativeComboboxViews::kViewClassName[] = 60 const char NativeComboboxViews::kViewClassName[] =
56 "views/NativeComboboxViews"; 61 "views/NativeComboboxViews";
57 62
58 NativeComboboxViews::NativeComboboxViews(Combobox* parent) 63 NativeComboboxViews::NativeComboboxViews(Combobox* parent)
59 : combobox_(parent), 64 : combobox_(parent),
60 text_border_(new FocusableBorder()), 65 text_border_(new FocusableBorder()),
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 158
154 void NativeComboboxViews::OnBlur() { 159 void NativeComboboxViews::OnBlur() {
155 NOTREACHED(); 160 NOTREACHED();
156 } 161 }
157 162
158 ///////////////////////////////////////////////////////////////// 163 /////////////////////////////////////////////////////////////////
159 // NativeComboboxViews, NativeComboboxWrapper overrides: 164 // NativeComboboxViews, NativeComboboxWrapper overrides:
160 165
161 void NativeComboboxViews::UpdateFromModel() { 166 void NativeComboboxViews::UpdateFromModel() {
162 int max_width = 0; 167 int max_width = 0;
163 const gfx::Font &font = GetFont(); 168 const gfx::Font& font = GetFont();
164 169
165 MenuItemView* menu = new MenuItemView(this); 170 MenuItemView* menu = new MenuItemView(this);
166 // MenuRunner owns |menu|. 171 // MenuRunner owns |menu|.
167 dropdown_list_menu_runner_.reset(new MenuRunner(menu)); 172 dropdown_list_menu_runner_.reset(new MenuRunner(menu));
168 173
169 int num_items = combobox_->model()->GetItemCount(); 174 int num_items = combobox_->model()->GetItemCount();
170 for (int i = 0; i < num_items; ++i) { 175 for (int i = 0; i < num_items; ++i) {
171 string16 text = combobox_->model()->GetItemAt(i); 176 string16 text = combobox_->model()->GetItemAt(i);
172 177
173 // Inserting the Unicode formatting characters if necessary so that the 178 // Inserting the Unicode formatting characters if necessary so that the
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 SchedulePaint(); 266 SchedulePaint();
262 } 267 }
263 268
264 bool NativeComboboxViews::GetAccelerator(int id, ui::Accelerator* accel) { 269 bool NativeComboboxViews::GetAccelerator(int id, ui::Accelerator* accel) {
265 return false; 270 return false;
266 } 271 }
267 272
268 ///////////////////////////////////////////////////////////////// 273 /////////////////////////////////////////////////////////////////
269 // NativeComboboxViews private methods: 274 // NativeComboboxViews private methods:
270 275
271 const gfx::Font& NativeComboboxViews::GetFont() const {
272 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
273 return rb.GetFont(ResourceBundle::BaseFont);
274 }
275
276 void NativeComboboxViews::AdjustBoundsForRTLUI(gfx::Rect* rect) const { 276 void NativeComboboxViews::AdjustBoundsForRTLUI(gfx::Rect* rect) const {
277 rect->set_x(GetMirroredXForRect(*rect)); 277 rect->set_x(GetMirroredXForRect(*rect));
278 } 278 }
279 279
280 void NativeComboboxViews::PaintText(gfx::Canvas* canvas) { 280 void NativeComboboxViews::PaintText(gfx::Canvas* canvas) {
281 gfx::Insets insets = GetInsets(); 281 gfx::Insets insets = GetInsets();
282 282
283 canvas->Save(); 283 canvas->Save();
284 canvas->ClipRect(GetContentsBounds()); 284 canvas->ClipRect(GetContentsBounds());
285 285
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 356
357 #if defined(USE_AURA) 357 #if defined(USE_AURA)
358 // static 358 // static
359 NativeComboboxWrapper* NativeComboboxWrapper::CreateWrapper( 359 NativeComboboxWrapper* NativeComboboxWrapper::CreateWrapper(
360 Combobox* combobox) { 360 Combobox* combobox) {
361 return new NativeComboboxViews(combobox); 361 return new NativeComboboxViews(combobox);
362 } 362 }
363 #endif 363 #endif
364 364
365 } // namespace views 365 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/combobox/native_combobox_views.h ('k') | ui/views/controls/combobox/native_combobox_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698