Merge branch 'SheetToolBar' of https://github.com/Dogild/cappuccino into pr-1919

This commit is contained in:
Antoine Mercadal committed 2013-05-06 13:29:09 -07:00
commit e0d33a8e3f
15 files changed
+120 -10

No files matched your search

+35 -8
View File
@@ -29,6 +29,8 @@ var _CPStandardWindowViewDividerViewHeight = 1.0;
@implementation _CPTexturedWindowHeadView : CPView
{
BOOL _isSheet @accessors(setter=setSheet:);
_CPWindowView _parentView;
CPView _gradientView;
CPView _solidView;
@@ -66,10 +68,11 @@ var _CPStandardWindowViewDividerViewHeight = 1.0;
[super layoutSubviews];
var gradientHeight = [[CPTheme defaultTheme] valueForAttributeWithName:@"gradient-height" forClass:_CPStandardWindowView],
bounds = [self bounds];
bounds = [self bounds],
bezelHeadColor = [[CPTheme defaultTheme] valueForAttributeWithName:_isSheet ? @"bezel-head-sheet-color" : @"bezel-head-color" inState:[_parentView themeState] forClass:_CPStandardWindowView];
[_gradientView setFrame:CGRectMake(0.0, 0.0, CGRectGetWidth(bounds), gradientHeight)];
[_gradientView setBackgroundColor:[[CPTheme defaultTheme] valueForAttributeWithName:@"bezel-head-color" inState:[_parentView themeState] forClass:_CPStandardWindowView]];
[_gradientView setBackgroundColor:bezelHeadColor];
[_solidView setFrame:CGRectMake(0.0, gradientHeight, CGRectGetWidth(bounds), CGRectGetHeight(bounds) - gradientHeight)];
[_solidView setBackgroundColor:[[CPTheme defaultTheme] valueForAttributeWithName:@"solid-color" forClass:_CPStandardWindowView]];
@@ -97,6 +100,7 @@ var _CPStandardWindowViewDividerViewHeight = 1.0;
CPButton _minimizeButton;
BOOL _isDocumentEdited;
BOOL _isSheet;
}
+ (CPString)defaultThemeClass
@@ -110,6 +114,7 @@ var _CPStandardWindowViewDividerViewHeight = 1.0;
@"gradient-height": [CPNull null],
@"solid-color": [CPNull null],
@"bezel-head-color": [CPNull null],
@"bezel-head-sheet-color": [CPNull null],
@"divider-color": [CPColor blackColor],
@"body-color": [CPColor whiteColor],
@"title-bar-height": 32,
@@ -224,7 +229,14 @@ var _CPStandardWindowViewDividerViewHeight = 1.0;
width = CGRectGetWidth(bounds),
headHeight = [self toolbarMaxY];
if (_isSheet && _toolbarView && [self showsToolbar])
{
headHeight = [_toolbarView frameSize].height;
[_toolbarView setFrameOrigin:CGPointMake(0.0, 0.0)];
}
[_headView setFrameSize:CGSizeMake(width, headHeight)];
[_dividerView setFrame:CGRectMake(0.0, headHeight, width, _CPStandardWindowViewDividerViewHeight)];
var dividerMinY = 0,
@@ -312,12 +324,26 @@ var _CPStandardWindowViewDividerViewHeight = 1.0;
{
[super _enableSheet:enable inWindow:parentWindow];
[_headView setHidden:enable];
[_dividerView setHidden:enable];
_isSheet = enable;
[_headView setSheet:enable];
if (_toolbarView && [self showsToolbar])
{
[_headView setHidden:NO];
[_dividerView setHidden:NO];
}
else
{
[_headView setHidden:enable];
[_dividerView setHidden:enable];
}
[_closeButton setHidden:enable];
[_minimizeButton setHidden:enable];
[_titleField setHidden:enable];
[[self window] setMovable:!enable];
if (enable)
{
[_bodyView setBackgroundColor:[[CPTheme defaultTheme] valueForAttributeWithName:@"body-color" forClass:_CPDocModalWindowView]];
@@ -333,12 +359,13 @@ var _CPStandardWindowViewDividerViewHeight = 1.0;
var theWindow = [self window],
frame = [theWindow frame],
dividerHeight = [_dividerView frame].size.height,
dy;
dy = [self toolbarMaxY] + dividerHeight;
if (_toolbarView && [self showsToolbar])
dy = [[CPTheme defaultTheme] valueForAttributeWithName:@"gradient-height" forClass:_CPStandardWindowView];
if (enable)
dy = -[_headView frame].size.height;
else
dy = [self toolbarMaxY] + dividerHeight;
dy = -dy;
var newHeight = CGRectGetHeight(frame) + dy,
newWidth = CGRectGetWidth(frame);
+1
View File
@@ -2687,6 +2687,7 @@ var themedButtonValues = nil,
[
[@"gradient-height", 31.0],
[@"bezel-head-color", bezelHeadColor],
[@"bezel-head-sheet-color", solidColor],
[@"solid-color", solidColor],
[@"title-font", [CPFont boldSystemFontOfSize:CPFontCurrentSystemSize]],
Binary file not shown.

After

Width:  |  Height:  |  Size: 82 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 993 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 996 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 996 B

+9
View File
@@ -2070,6 +2070,14 @@ var themedButtonValues = nil,
height: 1.0
}),
bezelSheetHeadColor = PatternColor(
"window-standard-head-sheet-solid{position}.png",
{
positions: "full",
width: 5.0,
height: 1.0
}),
bezelColor = PatternColor(
"window-standard{position}.png",
{
@@ -2104,6 +2112,7 @@ var themedButtonValues = nil,
[@"bezel-head-color", bezelHeadColor["inactive"], CPThemeStateNormal],
[@"bezel-head-color", bezelHeadColor["@"], CPThemeStateKeyWindow],
[@"bezel-head-color", bezelHeadColor["@"], CPThemeStateMainWindow],
[@"bezel-head-sheet-color", bezelSheetHeadColor],
[@"solid-color", solidColor],
[@"title-font", [CPFont boldSystemFontOfSize:CPFontCurrentSystemSize]],
+75 -2
View File
@@ -12,6 +12,7 @@
{
CPWindow wind;
CPWindow sheet;
CPWindow secondSheet;
CPTextField textField;
}
@@ -21,10 +22,19 @@
[wind setMinSize:CGSizeMake(300, 200)];
[wind setTitle:@"Untitled"];
sheet = [[CPWindow alloc] initWithContentRect:CGRectMake(0, 0, 300, 100) styleMask:CPDocModalWindowMask | CPResizableWindowMask];
sheet = [[CPWindow alloc] initWithContentRect:CGRectMake(50, 50, 300, 100) styleMask:CPTitledWindowMask | CPResizableWindowMask];
[sheet setMinSize:CGSizeMake(300, 100)];
[sheet setMaxSize:CGSizeMake(600, 300)];
secondSheet = [[CPWindow alloc] initWithContentRect:CGRectMake(50, 50, 300, 50) styleMask:CPTitledWindowMask | CPResizableWindowMask];
[secondSheet setMinSize:CGSizeMake(300, 100)];
[secondSheet setMaxSize:CGSizeMake(600, 300)];
toolbar = [CPToolbar new];
[toolbar setDisplayMode:CPToolbarDisplayModeIconAndLabel]
[toolbar setDelegate:self];
[secondSheet setToolbar:toolbar];
var sheetContent = [sheet contentView];
textField = [[CPTextField alloc] initWithFrame:CGRectMake(10, 30, 280, 30)];
@@ -51,19 +61,50 @@
[sheetContent addSubview:okButton];
[sheetContent addSubview:cancelButton];
var secondSheetContent = [secondSheet contentView];
var okButton2 = [[CPButton alloc] initWithFrame:CGRectMake(180, 25, 50, buttonHeight)];
[okButton2 setTitle:"OK"];
[okButton2 setTarget:self];
[okButton2 setTag:1];
[okButton2 setAction:@selector(closeSecondSheet:)];
[okButton2 setAutoresizingMask:CPViewMinXMargin | CPViewMinYMargin];
var cancelButton2 = [[CPButton alloc] initWithFrame:CGRectMake(70, 25, 100, buttonHeight)];
[cancelButton2 setTitle:"Cancel"];
[cancelButton2 setTarget:self];
[cancelButton2 setTag:0];
[cancelButton2 setAction:@selector(closeSecondSheet:)];
[cancelButton2 setAutoresizingMask:CPViewMinXMargin | CPViewMinYMargin];
[secondSheetContent addSubview:okButton2];
[secondSheetContent addSubview:cancelButton2];
var displayButton = [[CPButton alloc] initWithFrame:CGRectMake(200, 150, 100, buttonHeight)];
[displayButton setTitle:"Display Sheet"];
[displayButton setTarget:self];
[displayButton setAction:@selector(displaySheet:)];
[[wind contentView] addSubview:displayButton];
var displayButton = [[CPButton alloc] initWithFrame:CGRectMake(160, 180, 180, buttonHeight)];
[displayButton setTitle:"Display Sheet with toolbar"];
[displayButton setTarget:self];
[displayButton setAction:@selector(displaySheetWithToolBar:)];
[[wind contentView] addSubview:displayButton];
[wind orderFront:self]
}
- (void)displaySheetWithToolBar:(id)sender
{
[CPApp beginSheet:secondSheet modalForWindow:wind modalDelegate:self didEndSelector:@selector(didEndSheet:returnCode:contextInfo:) contextInfo:nil];
}
- (void)displaySheet:(id)sender
{
[textField setStringValue:""];
[sheet makeFirstResponder:textField];
[sheet setToolbar:nil];
[CPApp beginSheet:sheet modalForWindow:wind modalDelegate:self didEndSelector:@selector(didEndSheet:returnCode:contextInfo:) contextInfo:nil];
}
@@ -73,14 +114,46 @@
[CPApp endSheet:sheet returnCode:[sender tag]];
}
- (void)closeSecondSheet:(id)sender
{
[CPApp endSheet:secondSheet returnCode:0];
}
- (void)didEndSheet:(CPWindow)aSheet returnCode:(int)returnCode contextInfo:(id)contextInfo
{
var str = [textField stringValue];
[sheet orderOut:self];
[aSheet orderOut:self];
if (returnCode == CPOKButton && [str length] > 0)
[wind setTitle:str];
}
- (CPArray)toolbarDefaultItemIdentifiers:(CPToolbar)toolbar
{
return ["item1", "item2"];
}
- (CPArray)toolbarAllowedItemIdentifiers:(CPToolbar)toolbar
{
return ["item1", "item2"];
}
- (CPToolbarItem)toolbar:(CPToolbar)toolbar itemForItemIdentifier:(CPString)itemIdentifier willBeInsertedIntoToolbar:(BOOL)flag
{
var toolbarItem = [[CPToolbarItem alloc] initWithItemIdentifier:itemIdentifier];
if (itemIdentifier == "item1")
{
[toolbarItem setLabel:@"Color"];
[toolbarItem setImage:[[CPImage alloc] initWithContentsOfFile:[[CPBundle mainBundle] pathForResource:@"CPImageNameColorPanel.png"] size:CGSizeMake(26, 29)]];
return toolbarItem;
}
else if (itemIdentifier == "item2")
{
[toolbarItem setLabel:@"Small New"];
[toolbarItem setImage:[[CPImage alloc] initWithContentsOfFile:[[CPBundle mainBundle] pathForResource:@"New.png"] size:CGSizeMake(16, 16)]];
return toolbarItem;
}
}
@end
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 455 B