| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_BUTTON_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_MENU_BUTTON_H_ |
| 6 #define CHROME_BROWSER_UI_COCOA_MENU_BUTTON_H_ | 6 #define CHROME_BROWSER_UI_COCOA_MENU_BUTTON_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 #import "chrome/browser/ui/cocoa/toolbar/toolbar_button.h" | 11 #import "chrome/browser/ui/cocoa/toolbar/toolbar_button.h" |
| 12 | 12 |
| 13 // This a button which displays a user-provided menu "attached" below it upon | 13 // This a button which displays a user-provided menu "attached" below it upon |
| 14 // being clicked or dragged (or clicked and held). It expects a | 14 // being clicked or dragged (or clicked and held). It expects a |
| 15 // |ClickHoldButtonCell| as cell. | 15 // |ClickHoldButtonCell| as cell. |
| 16 // | 16 // |
| 17 // There are two different behaviors of this button depending on the value of | 17 // There are two different behaviors of this button depending on the value of |
| 18 // the |openMenuOnClick| property. If YES, the target-action mechanism will be | 18 // the |openMenuOnClick| property. If YES, the target-action mechanism will be |
| 19 // handled internally to always show the menu when clicked. This behavior is | 19 // handled internally to always show the menu when clicked. This behavior is |
| 20 // used for the Wrench menu, for example. When the property is NO, the button | 20 // used for the Wrench menu, for example. When the property is NO, the button |
| 21 // can have a separate target-action but will open the menu when clicked and | 21 // can have a separate target-action but will open the menu when clicked and |
| 22 // held. This is used for the toolbar back/forward buttons, which have a | 22 // held. This is used for the toolbar back/forward buttons, which have a |
| 23 // primary action and the menu as a secondary click-hold action. The default | 23 // primary action and the menu as a secondary click-hold action. The default |
| 24 // value is NO so that custom actions can be hooked up in Interface Builder. | 24 // value is NO so that custom actions can be hooked up in Interface Builder. |
| 25 @interface MenuButton : ToolbarButton { | 25 @interface MenuButton : ToolbarButton { |
| 26 @private | 26 @private |
| 27 scoped_nsobject<NSMenu> attachedMenu_; | 27 base::scoped_nsobject<NSMenu> attachedMenu_; |
| 28 BOOL openMenuOnClick_; | 28 BOOL openMenuOnClick_; |
| 29 BOOL openMenuOnRightClick_; | 29 BOOL openMenuOnRightClick_; |
| 30 scoped_nsobject<NSPopUpButtonCell> popUpCell_; | 30 base::scoped_nsobject<NSPopUpButtonCell> popUpCell_; |
| 31 } | 31 } |
| 32 | 32 |
| 33 // The menu to display. Note that it should have no (i.e., a blank) title and | 33 // The menu to display. Note that it should have no (i.e., a blank) title and |
| 34 // that the 0-th entry should be blank (and won't be displayed). (This is | 34 // that the 0-th entry should be blank (and won't be displayed). (This is |
| 35 // because we use a pulldown list, for which Cocoa uses the 0-th item as "title" | 35 // because we use a pulldown list, for which Cocoa uses the 0-th item as "title" |
| 36 // in the button. This might change if we ever switch to a pop-up. Our direct | 36 // in the button. This might change if we ever switch to a pop-up. Our direct |
| 37 // use of the given NSMenu object means that the one can set and use NSMenu's | 37 // use of the given NSMenu object means that the one can set and use NSMenu's |
| 38 // delegate as usual.) | 38 // delegate as usual.) |
| 39 @property(retain, nonatomic) IBOutlet NSMenu* attachedMenu; | 39 @property(retain, nonatomic) IBOutlet NSMenu* attachedMenu; |
| 40 | 40 |
| 41 // Whether or not to open the menu when the button is clicked. Otherwise, the | 41 // Whether or not to open the menu when the button is clicked. Otherwise, the |
| 42 // menu will only be opened when clicked and held. | 42 // menu will only be opened when clicked and held. |
| 43 @property(assign, nonatomic) BOOL openMenuOnClick; | 43 @property(assign, nonatomic) BOOL openMenuOnClick; |
| 44 | 44 |
| 45 // Whether or not to open the menu when the right button is clicked. | 45 // Whether or not to open the menu when the right button is clicked. |
| 46 @property(assign, nonatomic) BOOL openMenuOnRightClick; | 46 @property(assign, nonatomic) BOOL openMenuOnRightClick; |
| 47 | 47 |
| 48 // Returns the rectangle that menus are anchored at. Can be overridden by | 48 // Returns the rectangle that menus are anchored at. Can be overridden by |
| 49 // subclasses, returns -bounds by default. | 49 // subclasses, returns -bounds by default. |
| 50 - (NSRect)menuRect; | 50 - (NSRect)menuRect; |
| 51 | 51 |
| 52 @end // @interface MenuButton | 52 @end // @interface MenuButton |
| 53 | 53 |
| 54 // Available for subclasses. | 54 // Available for subclasses. |
| 55 @interface MenuButton (Protected) | 55 @interface MenuButton (Protected) |
| 56 - (void)configureCell; | 56 - (void)configureCell; |
| 57 @end | 57 @end |
| 58 | 58 |
| 59 #endif // CHROME_BROWSER_UI_COCOA_MENU_BUTTON_H_ | 59 #endif // CHROME_BROWSER_UI_COCOA_MENU_BUTTON_H_ |
| OLD | NEW |