blob: 3cdf509122e261023cab1bb464dc87d68214c2ef (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "ui/base/cocoa/hover_image_button.h"
@implementation HoverImageButton
- (void)drawRect:(NSRect)rect {
if (hoverState_ == kHoverStateMouseDown && pressedImage_) {
[super setImage:pressedImage_.get()];
} else if (hoverState_ == kHoverStateMouseOver && hoverImage_) {
[super setImage:hoverImage_.get()];
} else {
[super setImage:defaultImage_.get()];
}
[super drawRect:rect];
}
- (void)setDefaultImage:(NSImage*)image {
defaultImage_.reset([image retain]);
}
- (void)setHoverImage:(NSImage*)image {
hoverImage_.reset([image retain]);
}
- (void)setPressedImage:(NSImage*)image {
pressedImage_.reset([image retain]);
}
@end
|