OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #import "chrome/browser/ui/cocoa/bubble_combobox.h" | 5 #import "chrome/browser/ui/cocoa/bubble_combobox.h" |
6 | 6 |
| 7 #include "base/strings/sys_string_conversions.h" |
7 #include "ui/base/models/combobox_model.h" | 8 #include "ui/base/models/combobox_model.h" |
8 #include "base/strings/sys_string_conversions.h" | |
9 | 9 |
10 @implementation BubbleCombobox | 10 @implementation BubbleCombobox |
11 | 11 |
12 - (id)initWithFrame:(NSRect)frame | 12 - (id)initWithFrame:(NSRect)frame |
13 pullsDown:(BOOL)pullsDown | 13 pullsDown:(BOOL)pullsDown |
14 model:(ui::ComboboxModel*)model { | 14 model:(ui::ComboboxModel*)model { |
15 if ((self = [super initWithFrame:frame pullsDown:pullsDown])) { | 15 if ((self = [super initWithFrame:frame pullsDown:pullsDown])) { |
16 [self setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; | 16 [self setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; |
17 [self setBordered:YES]; | 17 [self setBordered:YES]; |
18 [[self cell] setControlSize:NSSmallControlSize]; | 18 [[self cell] setControlSize:NSSmallControlSize]; |
19 | 19 |
20 for (int i = 0; i < model->GetItemCount(); ++i) { | 20 for (int i = 0; i < model->GetItemCount(); ++i) { |
21 if (model->IsItemSeparatorAt(i)) | 21 if (model->IsItemSeparatorAt(i)) |
22 [[self menu] addItem:[NSMenuItem separatorItem]]; | 22 [[self menu] addItem:[NSMenuItem separatorItem]]; |
23 else | 23 else |
24 [self addItemWithTitle:base::SysUTF16ToNSString(model->GetItemAt(i))]; | 24 [self addItemWithTitle:base::SysUTF16ToNSString(model->GetItemAt(i))]; |
25 } | 25 } |
26 | 26 |
27 [self selectItemAtIndex:model->GetDefaultIndex()]; | 27 [self selectItemAtIndex:model->GetDefaultIndex()]; |
28 } | 28 } |
29 return self; | 29 return self; |
30 } | 30 } |
31 | 31 |
32 @end | 32 @end |
OLD | NEW |