File: menu_button.h

package info (click to toggle)
chromium-browser 57.0.2987.98-1~deb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 2,637,852 kB
  • ctags: 2,544,394
  • sloc: cpp: 12,815,961; ansic: 3,676,222; python: 1,147,112; asm: 526,608; java: 523,212; xml: 286,794; perl: 92,654; sh: 86,408; objc: 73,271; makefile: 27,698; cs: 18,487; yacc: 13,031; tcl: 12,957; pascal: 4,875; ml: 4,716; lex: 3,904; sql: 3,862; ruby: 1,982; lisp: 1,508; php: 1,368; exp: 404; awk: 325; csh: 117; jsp: 39; sed: 37
file content (59 lines) | stat: -rw-r--r-- 2,488 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_UI_COCOA_MENU_BUTTON_H_
#define CHROME_BROWSER_UI_COCOA_MENU_BUTTON_H_

#import <Cocoa/Cocoa.h>

#include "base/mac/scoped_nsobject.h"
#import "chrome/browser/ui/cocoa/toolbar/toolbar_button_cocoa.h"

// This a button which displays a user-provided menu "attached" below it upon
// being clicked or dragged (or clicked and held). It expects a
// |ClickHoldButtonCell| as cell.
//
// There are two different behaviors of this button depending on the value of
// the |openMenuOnClick| property. If YES, the target-action mechanism will be
// handled internally to always show the menu when clicked. This behavior is
// used for the App menu, for example. When the property is NO, the button can
// have a separate target-action but will open the menu when clicked and held.
// This is used for the toolbar back/forward buttons, which have a primary
// action and the menu as a secondary click-hold action. The default value is NO
// so that custom actions can be hooked up in Interface Builder.
@interface MenuButton : ToolbarButton {
 @private
  base::scoped_nsobject<NSMenu> attachedMenu_;
  BOOL openMenuOnClick_;
  BOOL openMenuOnRightClick_;
  base::scoped_nsobject<NSPopUpButtonCell> popUpCell_;
}

// The menu to display. Note that it should have no (i.e., a blank) title and
// that the 0-th entry should be blank (and won't be displayed). (This is
// because we use a pulldown list, for which Cocoa uses the 0-th item as "title"
// in the button. This might change if we ever switch to a pop-up. Our direct
// use of the given NSMenu object means that the one can set and use NSMenu's
// delegate as usual.)
@property(retain, nonatomic) IBOutlet NSMenu* attachedMenu;

// Whether or not to open the menu when the button is clicked. Otherwise, the
// menu will only be opened when clicked and held.
@property(assign, nonatomic) BOOL openMenuOnClick;

// Whether or not to open the menu when the right button is clicked.
@property(assign, nonatomic) BOOL openMenuOnRightClick;

// Returns the rectangle that menus are anchored at. Can be overridden by
// subclasses, returns -bounds by default.
- (NSRect)menuRect;

@end  // @interface MenuButton

// Available for subclasses.
@interface MenuButton (Protected)
- (void)configureCell;
@end

#endif  // CHROME_BROWSER_UI_COCOA_MENU_BUTTON_H_