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"
16 namespace image_button_cell
{
24 // The same as above, but for non-main, non-key windows.
25 kDefaultStateBackground
,
26 kHoverStateBackground
,
30 } // namespace ImageButtonCell
34 // Sent from an ImageButtonCell to its view when the mouse enters or exits the
36 - (void)mouseInsideStateDidChange
:(BOOL
)isInside
;
39 // A button cell that can disable a different image for each possible button
40 // state. Images are specified by image IDs.
41 @interface ImageButtonCell
: NSButtonCell
{
44 // At most one of these two fields will be non-null.
46 base::scoped_nsobject
<NSImage
> image
;
47 } image_
[image_button_cell::kButtonStateCount
];
51 @
property(assign
, nonatomic
) BOOL isMouseInside
;
53 // Gets the image for the given button state. Will load from a resource pak if
54 // the image was originally set using an image ID.
55 - (NSImage
*)imageForState
:(image_button_cell::ButtonState
)state
56 view
:(NSView
*)controlView
;
58 // Sets the image for the given button state using an image ID.
59 // The image will be lazy loaded from a resource pak -- important because
60 // this is in the hot path for startup.
61 - (void)setImageID
:(NSInteger
)imageID
62 forButtonState
:(image_button_cell::ButtonState
)state
;
64 // Sets the image for the given button state using an image.
65 - (void)setImage
:(NSImage
*)image
66 forButtonState
:(image_button_cell::ButtonState
)state
;
68 // Gets the alpha to use to draw the button for the current window focus state.
69 - (CGFloat
)imageAlphaForWindowState
:(NSWindow
*)window
;
71 // Returns the theme provider for the given |window|; this allows subclasses to
72 // pass in a different theme provider to use if appropriate.
73 - (ui::ThemeProvider
*)themeProviderForWindow
:(NSWindow
*)window
;
75 // Draws the cell's image within |cellFrame|.
76 - (void)drawImageWithFrame
:(NSRect
)cellFrame inView
:(NSView
*)controlView
;
78 // If |controlView| is a first responder then draws a blue focus ring.
79 - (void)drawFocusRingWithFrame
:(NSRect
)cellFrame inView
:(NSView
*)controlView
;
83 #endif // CHROME_BROWSER_UI_COCOA_IMAGE_BUTTON_CELL_H_