make find panel more consistent with other cocoa apps (bug 160771)

This commit is contained in:
pinkerton%netscape.com 2003-11-13 18:21:02 +00:00
Родитель 3aa8002f59
Коммит e34103d6a5
5 изменённых файлов: 86 добавлений и 68 удалений

Просмотреть файл

@ -41,13 +41,16 @@
IBOutlet NSTextField* mSearchField;
IBOutlet NSButton* mIgnoreCaseBox;
IBOutlet NSButton* mWrapAroundBox;
IBOutlet NSButton* mSearchBackwardsBox;
IBOutlet NSButton* mFindButton;
IBOutlet NSButton* mFindNextButton;
IBOutlet NSButton* mFindPrevButton;
}
- (IBAction) find: (id)aSender;
- (IBAction) findNextButton: (id)aSender;
- (IBAction) findPreviousButton: (id)aSender;
- (IBAction) findNextAndOrderOut: (id)aSender;
// delegates for NSTextView
- (void)controlTextDidChange:(NSNotification *)aNotification;
- (void)loadFindStringFromPasteboard;
- (void)putFindStringOnPasteboard;
@end

Просмотреть файл

@ -39,75 +39,121 @@
#import "Find.h"
@interface FindDlgController(Private)
- (NSString*)getSearchText;
- (NSString*)getSearchText;
- (BOOL)find:(BOOL)searchBack;
@end
@implementation FindDlgController
- (void)loadFindStringFromPasteboard
{
NSPasteboard *pasteboard = [NSPasteboard pasteboardWithName:NSFindPboard];
if ([[pasteboard types] containsObject:NSStringPboardType]) {
NSString *string = [pasteboard stringForType:NSStringPboardType];
if (string && [string length]) {
[mSearchField setStringValue: string];
[mFindNextButton setEnabled:YES];
[mFindPrevButton setEnabled:YES];
}
}
}
- (void)putFindStringOnPasteboard
{
NSPasteboard *pasteboard = [NSPasteboard pasteboardWithName:NSFindPboard];
[pasteboard declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:nil];
[pasteboard setString:[mSearchField stringValue] forType:NSStringPboardType];
}
//
// -find
//
// User clicked the find button, send the action to the window controller of the
// frontmost browser window. If we found something, hide the window. If not, beep.
// Performs the actual search. returns YES on success.
//
-(IBAction) find: (id)aSender
-(BOOL) find:(BOOL)searchBack
{
NSWindowController* controller = [[NSApp mainWindow] windowController];
if ( [controller conformsToProtocol:@protocol(Find)] ) {
id<Find> browserController = controller;
BOOL ignoreCase = [mIgnoreCaseBox state];
BOOL wrapSearch = [mWrapAroundBox state];
BOOL searchBack = [mSearchBackwardsBox state];
BOOL found = [browserController findInPageWithPattern:[mSearchField stringValue]
caseSensitive:!ignoreCase wrap:wrapSearch
backwards:searchBack];
if (! found )
NSBeep();
// we stay open
}
return [browserController findInPageWithPattern:[mSearchField stringValue] caseSensitive:!ignoreCase wrap:wrapSearch backwards:searchBack];
}
else
return NO;
}
- (IBAction) findNextButton: (id)aSender
{
[self putFindStringOnPasteboard];
if (![self find:NO])
NSBeep();
}
- (IBAction) findPreviousButton: (id)aSender
{
[self putFindStringOnPasteboard];
if (![self find:YES])
NSBeep();
}
- (IBAction) findNextAndOrderOut: (id)aSender
{
[self putFindStringOnPasteboard];
if (![self find:NO])
NSBeep();
else
[self close];
}
//
// controlTextDidChange
// -controlTextDidChange:
//
// Check if there is anything in the text field, and if not, disable the find button
//
- (void)controlTextDidChange:(NSNotification *)aNotification
{
if ( [[mSearchField stringValue] length] )
[mFindButton setEnabled:YES];
else
[mFindButton setEnabled:NO];
if ( [[mSearchField stringValue] length] ) {
[mFindNextButton setEnabled:YES];
[mFindPrevButton setEnabled:YES];
}
else {
[mFindNextButton setEnabled:NO];
[mFindPrevButton setEnabled:NO];
}
}
//
// -getSearchText
//
// Retrieve the most recent search string
//
- (NSString*)getSearchText
{
NSWindowController* controller = [[NSApp mainWindow] windowController];
if (![controller conformsToProtocol:@protocol(Find)])
return nil;
NSPasteboard *findPboard = [NSPasteboard pasteboardWithName:NSFindPboard];
if ([[findPboard types] indexOfObject:NSStringPboardType] != NSNotFound)
return [findPboard stringForType:NSStringPboardType];
id<Find> browserController = controller;
return [browserController lastFindText];
return [NSString string];
}
//
// -showWindow:
//
// override to set the current search text in the text area before showing
// the window
//
- (IBAction)showWindow:(id)sender
{
// Sync our text field with the most recent browser search string.
// We assume here that the frontmost window is a browser window.
NSWindowController* controller = [[NSApp mainWindow] windowController];
if ( [controller conformsToProtocol:@protocol(Find)] ) {
id<Find> browserController = controller;
[mSearchField setStringValue:[browserController lastFindText]];
}
[mSearchField setStringValue:[self getSearchText]];
[super showWindow:sender];
}
-(void)windowDidLoad
{
[mSearchField setStringValue:[self getSearchText]];
}
@end

Просмотреть файл

@ -1,19 +0,0 @@
{
IBClasses = (
{
ACTIONS = {find = id; };
CLASS = FindDlgController;
LANGUAGE = ObjC;
OUTLETS = {
mFindButton = NSButton;
mIgnoreCaseBox = NSButton;
mSearchBackwardsBox = NSButton;
mSearchField = NSTextField;
mWrapAroundBox = NSButton;
};
SUPERCLASS = NSWindowController;
},
{CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }
);
IBVersion = 1;
}

Просмотреть файл

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
<plist version="0.9">
<dict>
<key>IBDocumentLocation</key>
<string>180 86 356 240 0 0 1152 746 </string>
<key>IBFramework Version</key>
<string>248.0</string>
<key>IBSystem Version</key>
<string>5S66</string>
</dict>
</plist>

Двоичные данные
chimera/resources/localized/English.lproj/FindDialog.nib/objects.nib сгенерированный

Двоичный файл не отображается.