OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_wi
ndow.h" |
| 6 |
| 7 #import "base/memory/scoped_nsobject.h" |
| 8 #import "chrome/browser/ui/constrained_window.h" |
| 9 #include "skia/ext/skia_utils_mac.h" |
| 10 |
| 11 // The content view for the custom window. |
| 12 @interface ConstrainedWindowCustomWindowContentView : NSView |
| 13 @end |
| 14 |
| 15 @implementation ConstrainedWindowCustomWindow |
| 16 |
| 17 - (id)initWithContentRect:(NSRect)contentRect { |
| 18 if ((self = [super initWithContentRect:contentRect |
| 19 styleMask:NSBorderlessWindowMask |
| 20 backing:NSBackingStoreBuffered |
| 21 defer:NO])) { |
| 22 [self setHasShadow:YES]; |
| 23 [self setBackgroundColor:[NSColor clearColor]]; |
| 24 [self setOpaque:NO]; |
| 25 scoped_nsobject<NSView> content_view( |
| 26 [[ConstrainedWindowCustomWindowContentView alloc] |
| 27 initWithFrame:NSZeroRect]); |
| 28 [self setContentView:content_view]; |
| 29 } |
| 30 return self; |
| 31 } |
| 32 |
| 33 - (BOOL)canBecomeKeyWindow { |
| 34 return YES; |
| 35 } |
| 36 |
| 37 @end |
| 38 |
| 39 @implementation ConstrainedWindowCustomWindowContentView |
| 40 |
| 41 - (void)drawRect:(NSRect)rect { |
| 42 NSBezierPath* path = [NSBezierPath |
| 43 bezierPathWithRoundedRect:[self bounds] |
| 44 xRadius:ConstrainedWindow::kBorderRadius |
| 45 yRadius:ConstrainedWindow::kBorderRadius]; |
| 46 [gfx::SkColorToCalibratedNSColor(ConstrainedWindow::kBackgroundColor) set]; |
| 47 [path fill]; |
| 48 } |
| 49 |
| 50 @end |
OLD | NEW |