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. 4 5 #import "ui/base/cocoa/hover_image_button.h" 6 7 @implementation HoverImageButton 8 9 - (void)drawRect:(NSRect)rect { 10 if (hoverState_ == kHoverStateMouseDown && pressedImage_) { 11 [super setImage:pressedImage_.get()]; 12 } else if (hoverState_ == kHoverStateMouseOver && hoverImage_) { 13 [super setImage:hoverImage_.get()]; 14 } else { 15 [super setImage:defaultImage_.get()]; 16 } 17 18 [super drawRect:rect]; 19 } 20 21 - (void)setDefaultImage:(NSImage*)image { 22 defaultImage_.reset([image retain]); 23 } 24 25 - (void)setHoverImage:(NSImage*)image { 26 hoverImage_.reset([image retain]); 27 } 28 29 - (void)setPressedImage:(NSImage*)image { 30 pressedImage_.reset([image retain]); 31 } 32 33 @end 34