API  0.9.6
 All Classes Files Functions Variables Macros Groups Pages
CPShadow.j
Go to the documentation of this file.
1 /*
2  * CPShadow.j
3  * AppKit
4  *
5  * Created by Francisco Tolmasky.
6  * Copyright 2008, 280 North, Inc.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 
24 
31 @implementation CPShadow : CPObject
32 {
33  CPSize _offset;
34  float _blurRadius;
35  CPColor _color;
36 
37  CPString _cssString;
38 }
39 
47 + (id)shadowWithOffset:(CGSize)anOffset blurRadius:(float)aBlurRadius color:(CPColor)aColor
48 {
49  return [[CPShadow alloc] _initWithOffset:anOffset blurRadius:aBlurRadius color:aColor];
50 }
51 
52 /* @ignore */
53 - (id)_initWithOffset:(CPSize)anOffset blurRadius:(float)aBlurRadius color:(CPColor)aColor
54 {
55  self = [super init];
56 
57  if (self)
58  {
59  _offset = anOffset;
60  _blurRadius = aBlurRadius;
61  _color = aColor;
62 
63  _cssString = [_color cssString] + " " + ROUND(anOffset.width) + @"px " + ROUND(anOffset.height) + @"px " + ROUND(_blurRadius) + @"px";
64  }
65 
66  return self;
67 }
68 
72 - (CGSize)shadowOffset
73 {
74  return _offset;
75 }
76 
80 - (float)shadowBlurRadius
81 {
82  return _blurRadius;
83 }
84 
88 - (CPColor)shadowColor
89 {
90  return _color;
91 }
92 
96 - (CPString)cssString
97 {
98  return _cssString;
99 }
100 
101 @end