API  0.9.7
 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  CGSize _offset;
34  float _blurRadius;
35  CPColor _color;
36 }
37 
45 + (id)shadowWithOffset:(CGSize)anOffset blurRadius:(float)aBlurRadius color:(CPColor)aColor
46 {
47  return [[CPShadow alloc] _initWithOffset:anOffset blurRadius:aBlurRadius color:aColor];
48 }
49 
50 /* @ignore */
51 - (id)_initWithOffset:(CGSize)anOffset blurRadius:(float)aBlurRadius color:(CPColor)aColor
52 {
53  self = [super init];
54 
55  if (self)
56  {
57  _offset = anOffset;
58  _blurRadius = aBlurRadius;
59  _color = aColor;
60  }
61 
62  return self;
63 }
64 
65 - (void)set
66 {
68 
69  CGContextSetShadowWithColor(context, _offset, _blurRadius, _color);
70 }
71 
75 - (CPString)cssString
76 {
77  return [_color cssString] + " " + ROUND(_offset.width) + @"px " + ROUND(_offset.height) + @"px " + ROUND(_blurRadius) + @"px";
78 }
79 
80 @end
81 
83 
87 - (CGSize)shadowOffset
88 {
89  return _offset;
90 }
91 
95 - (void)setShadowOffset:(CGSize)aValue
96 {
97  _offset = aValue;
98 }
99 
103 - (float)shadowBlurRadius
104 {
105  return _blurRadius;
106 }
107 
111 - (void)setShadowBlurRadius:(float)aValue
112 {
113  _blurRadius = aValue;
114 }
115 
119 - (CPColor)shadowColor
120 {
121  return _color;
122 }
123 
127 - (void)setShadowColor:(CPColor)aValue
128 {
129  _color = aValue;
130 }
131 
132 @end