1 // Copyright (c) 2012 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 #import "chrome/browser/ui/cocoa/download/download_show_all_button.h"
7 #include "base/logging.h"
8 #import "chrome/browser/ui/cocoa/download/download_show_all_cell.h"
9 #import "chrome/browser/ui/cocoa/nsview_additions.h"
10 #import "chrome/browser/ui/cocoa/view_id_util.h"
11 #include "grit/generated_resources.h"
12 #include "grit/theme_resources.h"
13 #include "ui/base/resource/resource_bundle.h"
14 #include "ui/gfx/image/image.h"
16 @implementation DownloadShowAllButton
18 - (void)awakeFromNib {
19 DCHECK([[self cell] isKindOfClass:[DownloadShowAllCell class]]);
20 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
21 NSImage* favicon = rb.GetNativeImageNamed(IDR_DOWNLOADS_FAVICON).ToNSImage();
22 [self setImage:favicon];
25 // GTM's layout tweaker calls sizeToFit to receive the desired width of views.
26 // By default, buttons will be only 14px high, but the Show All button needs to
29 NSRect oldRect = [self frame];
31 NSRect newRect = [self frame];
34 newRect.origin.y = oldRect.origin.y;
35 newRect.size.height = oldRect.size.height;
37 [self setFrame:newRect];
41 // Make this control opaque so that sub-pixel anti-aliasing works when
42 // CoreAnimation is enabled.
46 - (void)drawRect:(NSRect)rect {
47 NSView* downloadShelfView = [self ancestorWithViewID:VIEW_ID_DOWNLOAD_SHELF];
48 [self cr_drawUsingAncestor:downloadShelfView inRect:rect];
49 [super drawRect:rect];