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 #pragma once | 7 #pragma once |
8 | 8 |
9 #import <Cocoa/Cocoa.h> | 9 #import <Cocoa/Cocoa.h> |
10 | 10 |
11 #include "base/memory/scoped_nsobject.h" | 11 #include "base/memory/scoped_nsobject.h" |
12 #import "chrome/browser/ui/cocoa/toolbar/toolbar_button.h" | 12 #import "chrome/browser/ui/cocoa/toolbar/toolbar_button.h" |
13 | 13 |
14 // This a button which displays a user-provided menu "attached" below it upon | 14 // This a button which displays a user-provided menu "attached" below it upon |
15 // being clicked or dragged (or clicked and held). It expects a | 15 // being clicked or dragged (or clicked and held). It expects a |
16 // |ClickHoldButtonCell| as cell. | 16 // |ClickHoldButtonCell| as cell. |
17 // | 17 // |
18 // There are two different behaviors of this button depending on the value of | 18 // There are two different behaviors of this button depending on the value of |
19 // the |openMenuOnClick| property. If YES, the target-action mechanism will be | 19 // the |openMenuOnClick| property. If YES, the target-action mechanism will be |
20 // handled internally to always show the menu when clicked. This behavior is | 20 // handled internally to always show the menu when clicked. This behavior is |
21 // used for the Wrench menu, for example. When the property is NO, the button | 21 // used for the Wrench menu, for example. When the property is NO, the button |
22 // can have a separate target-action but will open the menu when clicked and | 22 // can have a separate target-action but will open the menu when clicked and |
23 // held. This is used for the toolbar back/forward buttons, which have a | 23 // held. This is used for the toolbar back/forward buttons, which have a |
24 // primary action and the menu as a secondary click-hold action. The default | 24 // primary action and the menu as a secondary click-hold action. The default |
25 // value is NO so that custom actions can be hooked up in Interface Builder. | 25 // value is NO so that custom actions can be hooked up in Interface Builder. |
26 @interface MenuButton : ToolbarButton { | 26 @interface MenuButton : ToolbarButton { |
27 @private | 27 @private |
28 scoped_nsobject<NSMenu> attachedMenu_; | 28 scoped_nsobject<NSMenu> attachedMenu_; |
29 BOOL attachedMenuEnabled_; | |
30 BOOL openMenuOnClick_; | 29 BOOL openMenuOnClick_; |
31 BOOL openMenuOnRightClick_; | 30 BOOL openMenuOnRightClick_; |
32 scoped_nsobject<NSPopUpButtonCell> popUpCell_; | 31 scoped_nsobject<NSPopUpButtonCell> popUpCell_; |
33 } | 32 } |
34 | 33 |
35 // The menu to display. Note that it should have no (i.e., a blank) title and | 34 // The menu to display. Note that it should have no (i.e., a blank) title and |
36 // that the 0-th entry should be blank (and won't be displayed). (This is | 35 // that the 0-th entry should be blank (and won't be displayed). (This is |
37 // because we use a pulldown list, for which Cocoa uses the 0-th item as "title" | 36 // because we use a pulldown list, for which Cocoa uses the 0-th item as "title" |
38 // in the button. This might change if we ever switch to a pop-up. Our direct | 37 // in the button. This might change if we ever switch to a pop-up. Our direct |
39 // use of the given NSMenu object means that the one can set and use NSMenu's | 38 // use of the given NSMenu object means that the one can set and use NSMenu's |
(...skipping 12 matching lines...) Expand all Loading... |
52 - (NSRect)menuRect; | 51 - (NSRect)menuRect; |
53 | 52 |
54 @end // @interface MenuButton | 53 @end // @interface MenuButton |
55 | 54 |
56 // Available for subclasses. | 55 // Available for subclasses. |
57 @interface MenuButton (Protected) | 56 @interface MenuButton (Protected) |
58 - (void)configureCell; | 57 - (void)configureCell; |
59 @end | 58 @end |
60 | 59 |
61 #endif // CHROME_BROWSER_UI_COCOA_MENU_BUTTON_H_ | 60 #endif // CHROME_BROWSER_UI_COCOA_MENU_BUTTON_H_ |
OLD | NEW |