Fixed deallocation cleanup

Minor view changes

Sketching path bar to use for search as hint to where the entries are
Some experiments with the filter bar (extracted the view to a separate nib)
This commit is contained in:
michael starke
2013-02-25 03:31:55 +01:00
parent 1b878c4d0b
commit 841647a3ed
25 changed files with 1151 additions and 852 deletions

View File

@@ -39,6 +39,14 @@ NSString *const MPToolbarItemSearch = @"Search";
return self;
}
- (void)dealloc
{
self.toolbarItems = nil;
self.toolbarIdentifiers = nil;
self.toolbarImages = nil;
[super dealloc];
}
- (NSToolbarItem *)toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSString *)itemIdentifier willBeInsertedIntoToolbar:(BOOL)flag {
NSToolbarItem *item = self.toolbarItems[ itemIdentifier ];
if( !item ) {
@@ -49,20 +57,25 @@ NSString *const MPToolbarItemSearch = @"Search";
NSString *label = NSLocalizedString(itemIdentifier, @"");
[item setLabel:label];
[item release];
if([itemIdentifier isEqualToString:MPToolbarItemSearch]) {
NSSearchField *searchfield = [[NSSearchField alloc] initWithFrame:NSMakeRect(0, 0, 70, 32)];
[item setView:searchfield];
[searchfield setAction:@selector(updateFilter:)];
[[searchfield cell] setSendsSearchStringImmediately:NO];
[[searchfield cell] addObserver:self forKeyPath:@"controlSize" options:0 context:NULL];
[[[searchfield cell] cancelButtonCell] setTarget:nil];
[[[searchfield cell] cancelButtonCell] setAction:@selector(clearFilter:)];
[searchfield release];
self.searchItem = item;
}
else if([itemIdentifier isEqualToString:MPToolbarItemAction]) {
NSPopUpButton *popupButton = [[NSPopUpButton alloc] initWithFrame:NSMakeRect(0, 0, 50, 32) pullsDown:YES];
[[popupButton cell] addObserver:self forKeyPath:@"controlSize" options:0 context:NULL];
[[popupButton cell] setBezelStyle:NSTexturedRoundedBezelStyle];
[[popupButton cell] setImageScaling:NSImageScaleProportionallyDown];
[popupButton setTitle:@""];
[popupButton sizeToFit];
/*
Built menu
*/
@@ -72,14 +85,17 @@ NSString *const MPToolbarItemSearch = @"Search";
[menu addItem:menuItem];
[menu addItemWithTitle:@"Foo" action:NULL keyEquivalent:@""];
[menu addItemWithTitle:@"Bar" action:NULL keyEquivalent:@""];
[popupButton setMenu:menu];
NSRect newFrame = [popupButton frame];
newFrame.size.width += 20;
[popupButton setFrame:newFrame];
[popupButton setMenu:menu];
/*
Cleanup
*/
[menuItem release];
[menu release];
[popupButton sizeToFit];
[item setView:popupButton];
[popupButton release];
@@ -88,13 +104,16 @@ NSString *const MPToolbarItemSearch = @"Search";
NSButton *button = [[NSButton alloc] initWithFrame:NSMakeRect(0, 0, 32, 32)];
[[button cell] setBezelStyle:NSTexturedRoundedBezelStyle];
[[button cell] setImageScaling:NSImageScaleProportionallyDown];
[button setTitle:@""];
[button setTitle:itemIdentifier];
[button setButtonType:NSMomentaryPushInButton];
NSImage *image = self.toolbarImages[itemIdentifier];
[button setImage:image];
[button setImagePosition:NSImageOnly];
[button sizeToFit];
NSRect fittingRect = [button frame];
fittingRect.size.width = MAX( (CGFloat)32.0,fittingRect.size.width);
[button setFrame:fittingRect];
[item setView:button];
[button release];
}
@@ -123,5 +142,9 @@ NSString *const MPToolbarItemSearch = @"Search";
return imageDict;
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
NSLog(@"Path:%@: Objecte:%@", keyPath, object);
}
@end