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
{
20 // The same as above, but for non-main, non-key windows.
21 kDefaultStateBackground
,
22 kHoverStateBackground
,
26 } // namespace ImageButtonCell
30 // Sent from an ImageButtonCell to its view when the mouse enters or exits the
32 - (void)mouseInsideStateDidChange
:(BOOL
)isInside
;
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
{
40 // At most one of these two fields will be non-null.
42 base::scoped_nsobject
<NSImage
> image
;
43 } image_
[image_button_cell::kButtonStateCount
];
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
;
75 #endif // CHROME_BROWSER_UI_COCOA_IMAGE_BUTTON_CELL_H_