[Metrics] Make MetricsStateManager take a callback param to check if UMA is enabled.
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / image_button_cell.h
blobe1535d41fe337ddf06ba207e53040258de253313
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_COCOA_IMAGE_BUTTON_CELL_H_
6 #define CHROME_BROWSER_UI_COCOA_IMAGE_BUTTON_CELL_H_
8 #import <Cocoa/Cocoa.h>
10 #include "base/mac/scoped_nsobject.h"
12 namespace image_button_cell {
14 // Possible states
15 enum ButtonState {
16 kDefaultState = 0,
17 kHoverState,
18 kPressedState,
19 kDisabledState,
20 // The same as above, but for non-main, non-key windows.
21 kDefaultStateBackground,
22 kHoverStateBackground,
23 kButtonStateCount
26 } // namespace ImageButtonCell
28 @protocol ImageButton
29 @optional
30 // Sent from an ImageButtonCell to its view when the mouse enters or exits the
31 // cell.
32 - (void)mouseInsideStateDidChange:(BOOL)isInside;
33 @end
35 // A button cell that can disable a different image for each possible button
36 // state. Images are specified by image IDs.
37 @interface ImageButtonCell : NSButtonCell {
38 @private
39 struct {
40 // At most one of these two fields will be non-null.
41 int imageId;
42 base::scoped_nsobject<NSImage> image;
43 } image_[image_button_cell::kButtonStateCount];
44 BOOL isMouseInside_;
47 @property(assign, nonatomic) BOOL isMouseInside;
49 // Gets the image for the given button state. Will load from a resource pak if
50 // the image was originally set using an image ID.
51 - (NSImage*)imageForState:(image_button_cell::ButtonState)state
52 view:(NSView*)controlView;
54 // Sets the image for the given button state using an image ID.
55 // The image will be lazy loaded from a resource pak -- important because
56 // this is in the hot path for startup.
57 - (void)setImageID:(NSInteger)imageID
58 forButtonState:(image_button_cell::ButtonState)state;
60 // Sets the image for the given button state using an image.
61 - (void)setImage:(NSImage*)image
62 forButtonState:(image_button_cell::ButtonState)state;
64 // Gets the alpha to use to draw the button for the current window focus state.
65 - (CGFloat)imageAlphaForWindowState:(NSWindow*)window;
67 // Draws the cell's image within |cellFrame|.
68 - (void)drawImageWithFrame:(NSRect)cellFrame inView:(NSView*)controlView;
70 // If |controlView| is a first responder then draws a blue focus ring.
71 - (void)drawFocusRingWithFrame:(NSRect)cellFrame inView:(NSView*)controlView;
73 @end
75 #endif // CHROME_BROWSER_UI_COCOA_IMAGE_BUTTON_CELL_H_