OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 CHROME_BROWSER_UI_COCOA_MENU_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_MENU_CONTROLLER_H_ |
6 #define CHROME_BROWSER_UI_COCOA_MENU_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_COCOA_MENU_CONTROLLER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #import <Cocoa/Cocoa.h> | 9 #import <Cocoa/Cocoa.h> |
10 | 10 |
| 11 #import "base/mac/cocoa_protocols.h" |
11 #include "base/scoped_nsobject.h" | 12 #include "base/scoped_nsobject.h" |
12 | 13 |
13 namespace ui { | 14 namespace ui { |
14 class MenuModel; | 15 class MenuModel; |
15 } | 16 } |
16 | 17 |
17 // 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 |
18 // 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 |
19 // 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 |
20 // 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 |
21 // 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 |
22 // as it only maintains weak references. | 23 // as it only maintains weak references. |
23 @interface MenuController : NSObject { | 24 @interface MenuController : NSObject<NSMenuDelegate> { |
24 @protected | 25 @protected |
25 ui::MenuModel* model_; // weak | 26 ui::MenuModel* model_; // weak |
26 scoped_nsobject<NSMenu> menu_; | 27 scoped_nsobject<NSMenu> menu_; |
27 BOOL useWithPopUpButtonCell_; // If YES, 0th item is blank | 28 BOOL useWithPopUpButtonCell_; // If YES, 0th item is blank |
28 } | 29 } |
29 | 30 |
30 @property (nonatomic, assign) ui::MenuModel* model; | 31 @property (nonatomic, assign) ui::MenuModel* model; |
31 // Note that changing this will have no effect if you use | 32 // Note that changing this will have no effect if you use |
32 // |-initWithModel:useWithPopUpButtonCell:| or after the first call to |-menu|. | 33 // |-initWithModel:useWithPopUpButtonCell:| or after the first call to |-menu|. |
33 @property (nonatomic) BOOL useWithPopUpButtonCell; | 34 @property (nonatomic) BOOL useWithPopUpButtonCell; |
(...skipping 24 matching lines...) Expand all Loading... |
58 | 59 |
59 // Protected methods that subclassers can override. | 60 // Protected methods that subclassers can override. |
60 @interface MenuController (Protected) | 61 @interface MenuController (Protected) |
61 - (void)addItemToMenu:(NSMenu*)menu | 62 - (void)addItemToMenu:(NSMenu*)menu |
62 atIndex:(NSInteger)index | 63 atIndex:(NSInteger)index |
63 fromModel:(ui::MenuModel*)model | 64 fromModel:(ui::MenuModel*)model |
64 modelIndex:(int)modelIndex; | 65 modelIndex:(int)modelIndex; |
65 @end | 66 @end |
66 | 67 |
67 #endif // CHROME_BROWSER_UI_COCOA_MENU_CONTROLLER_H_ | 68 #endif // CHROME_BROWSER_UI_COCOA_MENU_CONTROLLER_H_ |
OLD | NEW |