BookmarkManager: Fix 'new folder text field size changes on clicking it' issue.
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / image_button_cell.h
blobe539284c71ce34be98d8a012d0386cf5d9b10666
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 ui {
13 class ThemeProvider;
16 namespace image_button_cell {
18 // Possible states
19 enum ButtonState {
20 kDefaultState = 0,
21 kHoverState,
22 kPressedState,
23 kDisabledState,
24 // The same as above, but for non-main, non-key windows.
25 kDefaultStateBackground,
26 kHoverStateBackground,
27 kButtonStateCount
30 } // namespace ImageButtonCell
32 @protocol ImageButton
33 @optional
34 // Sent from an ImageButtonCell to its view when the mouse enters or exits the
35 // cell.
36 - (void)mouseInsideStateDidChange:(BOOL)isInside;
37 @end
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 {
42 @private
43 struct {
44 // At most one of these two fields will be non-null.
45 int imageId;
46 base::scoped_nsobject<NSImage> image;
47 } image_[image_button_cell::kButtonStateCount];
48 BOOL isMouseInside_;
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;
81 @end
83 #endif // CHROME_BROWSER_UI_COCOA_IMAGE_BUTTON_CELL_H_