[-acceptsFirstResponder] new method, returns YES

[-initWithObject] set self as initialFirstResponder of the window
[-changeFont:] new method, change the font of the selected controls
[-selectObjects:] update the font in the font panel


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@10753 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Pierre-Yves Rivaille 2001-08-21 13:35:15 +00:00
parent ec56a5175e
commit ad8240812b

View file

@ -186,6 +186,7 @@ _constrainPointToBounds(NSPoint point, NSRect bounds)
- (BOOL) acceptsTypeFromArray: (NSArray*)types; - (BOOL) acceptsTypeFromArray: (NSArray*)types;
- (BOOL) activate; - (BOOL) activate;
- (id) initWithObject: (id)anObject inDocument: (id<IBDocuments>)aDocument; - (id) initWithObject: (id)anObject inDocument: (id<IBDocuments>)aDocument;
- (void) changeFont: (id) sender;
- (void) close; - (void) close;
- (void) closeSubeditors; - (void) closeSubeditors;
- (void) copySelection; - (void) copySelection;
@ -213,6 +214,11 @@ _constrainPointToBounds(NSPoint point, NSRect bounds)
return YES; return YES;
} }
- (BOOL) acceptsFirstResponder
{
return YES;
}
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{ {
[NSException raise: NSInternalInconsistencyException [NSException raise: NSInternalInconsistencyException
@ -1190,6 +1196,24 @@ static BOOL done_editing;
return YES; return YES;
} }
- (void)changeFont: (id)sender
{
NSEnumerator *enumerator = [selection objectEnumerator];
id anObject;
NSFont *newFont;
while ((anObject = [enumerator nextObject]))
{
if ([anObject respondsToSelector: @selector(font)]
&& [anObject respondsToSelector: @selector(setFont:)])
{
newFont = [sender convertFont: [anObject font]];
[anObject setFont: newFont];
}
}
return;
}
- (void) close - (void) close
{ {
NSAssert(isClosed == NO, NSInternalInconsistencyException); NSAssert(isClosed == NO, NSInternalInconsistencyException);
@ -1399,6 +1423,7 @@ static BOOL done_editing;
} }
[win setContentView: self]; [win setContentView: self];
ASSIGN(document, aDocument); ASSIGN(document, aDocument);
ASSIGN(edited, anObject); ASSIGN(edited, anObject);
selection = [NSMutableArray new]; selection = [NSMutableArray new];
@ -1412,6 +1437,7 @@ static BOOL done_editing;
[self registerForDraggedTypes: [NSArray arrayWithObjects: [self registerForDraggedTypes: [NSArray arrayWithObjects:
IBViewPboardType, GormLinkPboardType, nil]]; IBViewPboardType, GormLinkPboardType, nil]];
[win setInitialFirstResponder: self];
return self; return self;
} }
@ -1618,6 +1644,20 @@ static BOOL done_editing;
[selection removeObjectAtIndex: count]; [selection removeObjectAtIndex: count];
} }
} }
if ([selection count] == 1)
{
id item;
item = [selection objectAtIndex: 0];
if ([item respondsToSelector: @selector(font)]
&& [item respondsToSelector: @selector(setFont:)])
[[NSFontManager sharedFontManager] setSelectedFont: [item font]
isMultiple: NO];
}
else if ([selection count] > 0)
{
[[NSFontManager sharedFontManager] setSelectedFont: nil
isMultiple: YES];
}
} }
/* /*
* Now we must let the document (and hence the rest of the app) know * Now we must let the document (and hence the rest of the app) know