Added themable _CPDocModalWindowView

This commit is contained in:
Alexandre Wilhelm committed 2013-01-09 13:09:20 -08:00
1 parent 42868ecbee
commit 0e6df9d299
1 file changed
+25 -6
+25 -6
View File
@@ -9,6 +9,17 @@ var _CPStandardWindowViewBodyBackgroundColor = nil;
CPView _shadowView;
}
+ (CPString)defaultThemeClass
{
return @"doc-modal-window-view";
}
+ (id)themeAttributes
{
return [CPDictionary dictionaryWithObjects:[[CPColor whiteColor], [CPNull null], 8]
forKeys:[ @"body-color", @"attached-sheet-shadow-color", @"height-shadow"]];
}
+ (CPColor)bodyBackgroundColor
{
if (!_CPStandardWindowViewBodyBackgroundColor)
@@ -23,21 +34,17 @@ var _CPStandardWindowViewBodyBackgroundColor = nil;
if (self)
{
var theClass = [self class],
bounds = [self bounds];
var bounds = [self bounds];
_bodyView = [[CPView alloc] initWithFrame:_CGRectMake(0.0, 0.0, _CGRectGetWidth(bounds), _CGRectGetHeight(bounds))];
[_bodyView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
[_bodyView setBackgroundColor:[theClass bodyBackgroundColor]];
[_bodyView setHitTests:NO];
[self addSubview:_bodyView];
var bundle = [CPBundle bundleForClass:[CPWindow class]];
_shadowView = [[CPView alloc] initWithFrame:CGRectMake(0, 0, _CGRectGetWidth(bounds), 8)];
_shadowView = [[CPView alloc] initWithFrame:CGRectMake(0, 0, _CGRectGetWidth(bounds), [self valueForThemeAttribute:@"height-shadow"])];
[_shadowView setAutoresizingMask:CPViewWidthSizable];
[_shadowView setBackgroundColor:[CPColor colorWithPatternImage:[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPWindow/CPWindowAttachedSheetShadow.png"] size:CGSizeMake(9,8)]]];
[self addSubview:_shadowView];
}
@@ -59,5 +66,17 @@ var _CPStandardWindowViewBodyBackgroundColor = nil;
// do nothing, already a sheet
}
- (void)layoutSubviews
{
[super layoutSubviews];
var bounds = [self bounds];
[_bodyView setBackgroundColor:[self valueForThemeAttribute:@"body-color"]];
[_shadowView setFrame:CGRectMake(0,0, _CGRectGetWidth(bounds), [self valueForThemeAttribute:@"height-shadow"])];
[_shadowView setBackgroundColor:[self valueForThemeAttribute:@"attached-sheet-shadow-color"]];
}
@end