Home | History | Annotate | Download | only in cocoa
      1 // Copyright (c) 2010 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 #include "chrome/browser/ui/cocoa/vertical_gradient_view.h"
      6 
      7 @implementation VerticalGradientView
      8 
      9 - (NSGradient*)gradient {
     10   return gradient_;
     11 }
     12 
     13 - (void)setGradient:(NSGradient*)gradient {
     14   gradient_.reset([gradient retain]);
     15 }
     16 
     17 - (NSColor*)strokeColor {
     18   return strokeColor_;
     19 }
     20 
     21 - (void)setStrokeColor:(NSColor*)strokeColor {
     22   strokeColor_.reset([strokeColor retain]);
     23 }
     24 
     25 - (void)drawRect:(NSRect)rect {
     26   // Draw gradient.
     27   [[self gradient] drawInRect:[self bounds] angle:270];
     28 
     29   // Draw bottom stroke.
     30   NSColor* strokeColor = [self strokeColor];
     31   if (strokeColor) {
     32     [[self strokeColor] set];
     33     NSRect borderRect, contentRect;
     34     NSDivideRect([self bounds], &borderRect, &contentRect, 1, NSMinYEdge);
     35     NSRectFillUsingOperation(borderRect, NSCompositeSourceOver);
     36   }
     37 }
     38 
     39 @end
     40