mirror of
https://github.com/darlinghq/darling-cocotron.git
synced 2024-11-27 14:00:22 +00:00
NSSavePanel, NSSearchFieldCell fixes
This commit is contained in:
parent
1036031846
commit
215fea88e8
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2006-2007 Christopher J. W. Lloyd
|
||||
/* Copyright (c) 2006-2007 Christopher J. W. Lloyd <cjwl@objc.net>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
@ -10,6 +10,11 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
||||
|
||||
@class NSView;
|
||||
|
||||
enum {
|
||||
NSFileHandlingPanelCancelButton=NSCancelButton,
|
||||
NSFileHandlingPanelOKButton =NSOKButton,
|
||||
};
|
||||
|
||||
@interface NSSavePanel : NSPanel {
|
||||
NSString *_dialogTitle;
|
||||
|
||||
@ -25,7 +30,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
||||
|
||||
+(NSSavePanel *)savePanel;
|
||||
|
||||
|
||||
-(NSURL *)URL;
|
||||
-(NSString *)filename;
|
||||
|
||||
-(int)runModalForDirectory:(NSString *)directory file:(NSString *)file;
|
||||
@ -43,6 +48,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
||||
-(void)setTreatsFilePackagesAsDirectories:(BOOL)flag;
|
||||
|
||||
-(void)setAccessoryView:(NSView *)view;
|
||||
-(void)setCanCreateDirectories:(BOOL)value;
|
||||
-(void)setAllowedFileTypes:(NSArray *)value;
|
||||
-(void)setAllowsOtherFileTypes:(BOOL)value;
|
||||
|
||||
-(void)setMessage:(NSString*)message;
|
||||
-(NSString*)message;
|
||||
|
@ -1,16 +1,15 @@
|
||||
/* Copyright (c) 2006-2007 Christopher J. W. Lloyd, 2008 Johannes Fortmann
|
||||
/* Copyright (c) 2006-2007 Christopher J. W. Lloyd <cjwl@objc.net>, 2008 Johannes Fortmann
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
|
||||
// Original - Christopher Lloyd <cjwl@objc.net>
|
||||
#import <AppKit/NSSavePanel.h>
|
||||
#import <AppKit/NSView.h>
|
||||
#import <AppKit/NSApplication.h>
|
||||
#import <AppKit/NSDisplay.h>
|
||||
#import <AppKit/NSRaise.h>
|
||||
|
||||
@implementation NSSavePanel
|
||||
|
||||
@ -51,6 +50,10 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
||||
}
|
||||
}
|
||||
|
||||
-(NSURL *)URL {
|
||||
return [NSURL fileURLWithPath:[self filename]];
|
||||
}
|
||||
|
||||
-(NSString *)filename {
|
||||
id ret=nil;
|
||||
@synchronized(self)
|
||||
@ -168,8 +171,18 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
||||
_accessoryView=view;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Sheet methods
|
||||
-(void)setCanCreateDirectories:(BOOL)value {
|
||||
NSUnimplementedMethod();
|
||||
}
|
||||
|
||||
-(void)setAllowedFileTypes:(NSArray *)value {
|
||||
NSUnimplementedMethod();
|
||||
}
|
||||
|
||||
-(void)setAllowsOtherFileTypes:(BOOL)value {
|
||||
NSUnimplementedMethod();
|
||||
}
|
||||
|
||||
- (void)beginSheetForDirectory:(NSString *)path
|
||||
file:(NSString *)name
|
||||
modalForWindow:(NSWindow *)docWindow
|
||||
|
@ -9,10 +9,35 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
||||
#import <AppKit/NSSearchFieldCell.h>
|
||||
#import <AppKit/NSButtonCell.h>
|
||||
#import <AppKit/NSMenu.h>
|
||||
#import <AppKit/NSImage.h>
|
||||
#import <AppKit/NSRaise.h>
|
||||
|
||||
@implementation NSSearchFieldCell
|
||||
|
||||
-initWithCoder:(NSCoder *)coder {
|
||||
[super initWithCoder:coder];
|
||||
_searchButtonCell=[[NSButtonCell alloc] initImageCell:[NSImage imageNamed:@"NSSearchGlass"]];
|
||||
[_searchButtonCell setImageScaling:NSImageScaleProportionallyUpOrDown];
|
||||
_cancelButtonCell=[[NSButtonCell alloc] initImageCell:[NSImage imageNamed:@"NSSearchClose"]];
|
||||
[_cancelButtonCell setImageScaling:NSImageScaleProportionallyUpOrDown];
|
||||
return self;
|
||||
}
|
||||
|
||||
-initTextCell:(NSString *)string {
|
||||
[super initTextCell:string];
|
||||
_searchButtonCell=[[NSButtonCell alloc] initImageCell:[NSImage imageNamed:@"NSSearchGlass"]];
|
||||
[_searchButtonCell setImageScaling:NSImageScaleProportionallyUpOrDown];
|
||||
_cancelButtonCell=[[NSButtonCell alloc] initImageCell:[NSImage imageNamed:@"NSSearchClose"]];
|
||||
[_cancelButtonCell setImageScaling:NSImageScaleProportionallyUpOrDown];
|
||||
return self;
|
||||
}
|
||||
|
||||
-(void)dealloc {
|
||||
[_searchButtonCell release];
|
||||
[_cancelButtonCell release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
-(NSArray *)recentSearches {
|
||||
return _recentSearches;
|
||||
}
|
||||
@ -88,18 +113,25 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
||||
}
|
||||
|
||||
-(NSRect)searchTextRectForBounds:(NSRect)rect {
|
||||
NSUnimplementedMethod();
|
||||
return NSZeroRect;
|
||||
return [self titleRectForBounds:rect];
|
||||
}
|
||||
|
||||
-(NSRect)searchButtonRectForBounds:(NSRect)rect {
|
||||
NSUnimplementedMethod();
|
||||
return NSZeroRect;
|
||||
NSRect result=[self titleRectForBounds:rect];
|
||||
|
||||
result.size.width=result.size.height;
|
||||
result.origin.x-=result.size.width;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
-(NSRect)cancelButtonRectForBounds:(NSRect)rect {
|
||||
NSUnimplementedMethod();
|
||||
return NSZeroRect;
|
||||
NSRect result=[self titleRectForBounds:rect];
|
||||
|
||||
result.origin.x+=result.size.width;
|
||||
result.size.width=result.size.height;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
-(void)resetCancelButtonCell {
|
||||
@ -110,4 +142,30 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
||||
NSUnimplementedMethod();
|
||||
}
|
||||
|
||||
-(NSRect)titleRectForBounds:(NSRect)rect {
|
||||
CGFloat radius=rect.size.height/2;
|
||||
NSRect result=[super titleRectForBounds:rect];
|
||||
|
||||
result=NSInsetRect(result,radius,0);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
-(BOOL)trackMouse:(NSEvent *)event inRect:(NSRect)frame ofView:(NSView *)view untilMouseUp:(BOOL)untilMouseUp {
|
||||
if([_cancelButtonCell trackMouse:event inRect:[self cancelButtonRectForBounds:frame] ofView:view untilMouseUp:YES]){
|
||||
[self setStringValue:@""];
|
||||
return YES;
|
||||
}
|
||||
|
||||
return [super trackMouse:event inRect:frame ofView:view untilMouseUp:untilMouseUp];
|
||||
}
|
||||
|
||||
-(void)drawWithFrame:(NSRect)frame inView:(NSView *)control {
|
||||
[super drawWithFrame:frame inView:control];
|
||||
|
||||
[_searchButtonCell drawWithFrame:[self searchButtonRectForBounds:frame] inView:control];
|
||||
if([[self attributedStringValue] length]>0)
|
||||
[_cancelButtonCell drawWithFrame:[self cancelButtonRectForBounds:frame] inView:control];
|
||||
}
|
||||
|
||||
@end
|
||||
|
Loading…
Reference in New Issue
Block a user