| 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 | 7 |
| 8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
| 9 | 9 |
| 10 #include "base/memory/scoped_nsobject.h" | 10 #include "base/mac/scoped_nsobject.h" |
| 11 | 11 |
| 12 namespace image_button_cell { | 12 namespace image_button_cell { |
| 13 | 13 |
| 14 // Possible states | 14 // Possible states |
| 15 enum ButtonState { | 15 enum ButtonState { |
| 16 kDefaultState = 0, | 16 kDefaultState = 0, |
| 17 kHoverState, | 17 kHoverState, |
| 18 kPressedState, | 18 kPressedState, |
| 19 kDisabledState, | 19 kDisabledState, |
| 20 // The same as above, but for non-main, non-key windows. | 20 // The same as above, but for non-main, non-key windows. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 32 - (void)mouseInsideStateDidChange:(BOOL)isInside; | 32 - (void)mouseInsideStateDidChange:(BOOL)isInside; |
| 33 @end | 33 @end |
| 34 | 34 |
| 35 // A button cell that can disable a different image for each possible button | 35 // A button cell that can disable a different image for each possible button |
| 36 // state. Images are specified by image IDs. | 36 // state. Images are specified by image IDs. |
| 37 @interface ImageButtonCell : NSButtonCell { | 37 @interface ImageButtonCell : NSButtonCell { |
| 38 @private | 38 @private |
| 39 struct { | 39 struct { |
| 40 // At most one of these two fields will be non-null. | 40 // At most one of these two fields will be non-null. |
| 41 int imageId; | 41 int imageId; |
| 42 scoped_nsobject<NSImage> image; | 42 base::scoped_nsobject<NSImage> image; |
| 43 } image_[image_button_cell::kButtonStateCount]; | 43 } image_[image_button_cell::kButtonStateCount]; |
| 44 BOOL isMouseInside_; | 44 BOOL isMouseInside_; |
| 45 } | 45 } |
| 46 | 46 |
| 47 @property(assign, nonatomic) BOOL isMouseInside; | 47 @property(assign, nonatomic) BOOL isMouseInside; |
| 48 | 48 |
| 49 // Gets the image for the given button state. Will load from a resource pak if | 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. | 50 // the image was originally set using an image ID. |
| 51 - (NSImage*)imageForState:(image_button_cell::ButtonState)state | 51 - (NSImage*)imageForState:(image_button_cell::ButtonState)state |
| 52 view:(NSView*)controlView; | 52 view:(NSView*)controlView; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 63 | 63 |
| 64 // Gets the alpha to use to draw the button for the current window focus state. | 64 // Gets the alpha to use to draw the button for the current window focus state. |
| 65 - (CGFloat)imageAlphaForWindowState:(NSWindow*)window; | 65 - (CGFloat)imageAlphaForWindowState:(NSWindow*)window; |
| 66 | 66 |
| 67 // If |controlView| is a first responder then draws a blue focus ring. | 67 // If |controlView| is a first responder then draws a blue focus ring. |
| 68 - (void)drawFocusRingWithFrame:(NSRect)cellFrame inView:(NSView*)controlView; | 68 - (void)drawFocusRingWithFrame:(NSRect)cellFrame inView:(NSView*)controlView; |
| 69 | 69 |
| 70 @end | 70 @end |
| 71 | 71 |
| 72 #endif // CHROME_BROWSER_UI_COCOA_IMAGE_BUTTON_CELL_H_ | 72 #endif // CHROME_BROWSER_UI_COCOA_IMAGE_BUTTON_CELL_H_ |
| OLD | NEW |