OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef UI_BASE_COCOA_MENU_CONTROLLER_H_ | 5 #ifndef UI_BASE_COCOA_MENU_CONTROLLER_H_ |
6 #define UI_BASE_COCOA_MENU_CONTROLLER_H_ | 6 #define UI_BASE_COCOA_MENU_CONTROLLER_H_ |
7 | 7 |
8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 | 9 |
10 #include "base/memory/scoped_nsobject.h" | 10 #include "base/mac/scoped_nsobject.h" |
11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
12 #include "ui/base/ui_export.h" | 12 #include "ui/base/ui_export.h" |
13 | 13 |
14 namespace ui { | 14 namespace ui { |
15 class MenuModel; | 15 class MenuModel; |
16 } | 16 } |
17 | 17 |
18 // A controller for the cross-platform menu model. The menu that's created | 18 // A controller for the cross-platform menu model. The menu that's created |
19 // has the tag and represented object set for each menu item. The object is a | 19 // has the tag and represented object set for each menu item. The object is a |
20 // NSValue holding a pointer to the model for that level of the menu (to | 20 // NSValue holding a pointer to the model for that level of the menu (to |
21 // allow for hierarchical menus). The tag is the index into that model for | 21 // allow for hierarchical menus). The tag is the index into that model for |
22 // that particular item. It is important that the model outlives this object | 22 // that particular item. It is important that the model outlives this object |
23 // as it only maintains weak references. | 23 // as it only maintains weak references. |
24 UI_EXPORT | 24 UI_EXPORT |
25 @interface MenuController : NSObject<NSMenuDelegate> { | 25 @interface MenuController : NSObject<NSMenuDelegate> { |
26 @protected | 26 @protected |
27 ui::MenuModel* model_; // weak | 27 ui::MenuModel* model_; // weak |
28 scoped_nsobject<NSMenu> menu_; | 28 base::scoped_nsobject<NSMenu> menu_; |
29 BOOL useWithPopUpButtonCell_; // If YES, 0th item is blank | 29 BOOL useWithPopUpButtonCell_; // If YES, 0th item is blank |
30 BOOL isMenuOpen_; | 30 BOOL isMenuOpen_; |
31 } | 31 } |
32 | 32 |
33 @property(nonatomic, assign) ui::MenuModel* model; | 33 @property(nonatomic, assign) ui::MenuModel* model; |
34 // Note that changing this will have no effect if you use | 34 // Note that changing this will have no effect if you use |
35 // |-initWithModel:useWithPopUpButtonCell:| or after the first call to |-menu|. | 35 // |-initWithModel:useWithPopUpButtonCell:| or after the first call to |-menu|. |
36 @property(nonatomic) BOOL useWithPopUpButtonCell; | 36 @property(nonatomic) BOOL useWithPopUpButtonCell; |
37 | 37 |
38 + (string16)elideMenuTitle:(const string16&)title | 38 + (string16)elideMenuTitle:(const string16&)title |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 atIndex:(NSInteger)index | 79 atIndex:(NSInteger)index |
80 fromModel:(ui::MenuModel*)model; | 80 fromModel:(ui::MenuModel*)model; |
81 - (NSMenu*)menuFromModel:(ui::MenuModel*)model; | 81 - (NSMenu*)menuFromModel:(ui::MenuModel*)model; |
82 // Returns the maximum width for the menu item. Returns -1 to indicate | 82 // Returns the maximum width for the menu item. Returns -1 to indicate |
83 // that there's no maximum width. | 83 // that there's no maximum width. |
84 - (int)maxWidthForMenuModel:(ui::MenuModel*)model | 84 - (int)maxWidthForMenuModel:(ui::MenuModel*)model |
85 modelIndex:(int)modelIndex; | 85 modelIndex:(int)modelIndex; |
86 @end | 86 @end |
87 | 87 |
88 #endif // UI_BASE_COCOA_MENU_CONTROLLER_H_ | 88 #endif // UI_BASE_COCOA_MENU_CONTROLLER_H_ |
OLD | NEW |