OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_UI_COCOA_IMAGE_BUTTON_CELL_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_IMAGE_BUTTON_CELL_H_ |
6 #define CHROME_BROWSER_UI_COCOA_IMAGE_BUTTON_CELL_H_ | 6 #define CHROME_BROWSER_UI_COCOA_IMAGE_BUTTON_CELL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #import <Cocoa/Cocoa.h> | 9 #import <Cocoa/Cocoa.h> |
10 | 10 |
11 namespace image_button_cell { | 11 namespace image_button_cell { |
12 | 12 |
13 // Possible states | 13 // Possible states |
14 enum ButtonState { | 14 enum ButtonState { |
15 kDefaultState = 0, | 15 kDefaultState = 0, |
16 kHoverState, | 16 kHoverState, |
17 kPressedState, | 17 kPressedState, |
18 kDisabledState, | 18 kDisabledState, |
19 kButtonStateCount | 19 kButtonStateCount |
20 }; | 20 }; |
21 | 21 |
22 } // namespace ImageButtonCell | 22 } // namespace ImageButtonCell |
23 | 23 |
| 24 @protocol ImageButton |
| 25 @optional |
| 26 // Sent from an ImageButtonCell to it's view when the mouse enters or exits the |
| 27 // cell. |
| 28 - (void)mouseInsideStateDidChange:(BOOL)isInside; |
| 29 @end |
| 30 |
24 // A button cell that can disable a different image for each possible button | 31 // A button cell that can disable a different image for each possible button |
25 // state. Images are specified by image IDs. | 32 // state. Images are specified by image IDs. |
26 @interface ImageButtonCell : NSButtonCell { | 33 @interface ImageButtonCell : NSButtonCell { |
27 @private | 34 @private |
28 NSInteger imageID_[image_button_cell::kButtonStateCount]; | 35 NSInteger imageID_[image_button_cell::kButtonStateCount]; |
29 NSInteger overlayImageID_; | 36 NSInteger overlayImageID_; |
30 BOOL isMouseInside_; | 37 BOOL isMouseInside_; |
31 } | 38 } |
32 | 39 |
33 @property(assign, nonatomic) BOOL isMouseInside; | 40 @property(assign, nonatomic) BOOL isMouseInside; |
34 @property(assign, nonatomic) NSInteger overlayImageID; | 41 @property(assign, nonatomic) NSInteger overlayImageID; |
35 | 42 |
36 // Sets the image for the given button state using an image ID. | 43 // Sets the image for the given button state using an image ID. |
37 // The image will be lazy loaded from a resource pak. | 44 // The image will be lazy loaded from a resource pak. |
38 - (void)setImageID:(NSInteger)imageID | 45 - (void)setImageID:(NSInteger)imageID |
39 forButtonState:(image_button_cell::ButtonState)state; | 46 forButtonState:(image_button_cell::ButtonState)state; |
40 | 47 |
41 @end | 48 @end |
42 | 49 |
43 #endif // CHROME_BROWSER_UI_COCOA_IMAGE_BUTTON_CELL_H_ | 50 #endif // CHROME_BROWSER_UI_COCOA_IMAGE_BUTTON_CELL_H_ |
OLD | NEW |