Added some code which tries another way to change the font if the responder chain isn't sucessful in locating the object to call changeFont: on.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@20871 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2005-03-08 05:11:41 +00:00
parent fabc6eb8cc
commit c80afb4514
6 changed files with 126 additions and 2 deletions

View file

@ -1,3 +1,12 @@
2005-03-08 00:15 Gregory John Casamento <greg_casamento@yahoo.com>
* GNUmakefile: Added new files.
* GormDocument.h: Added header for InterfaceBuilder.h to get
the necessary interface declarations.
* GormDocument.m: Change to retain and release the last used
editor.
* NSFontManager+GormExtensions.[hm]: New files.
2005-03-07 22:18 Gregory John Casamento <greg_casamento@yahoo.com>
* GormDocument.m: Added code to make the window of the widget

View file

@ -182,6 +182,7 @@ Gorm_HEADERS = \
GormViewWithContentViewEditor.h \
GormViewWithSubviewsEditor.h \
NSColorWell+GormExtensions.h \
NSFontManager+GormExtensions.h \
NSView+GormExtensions.h
Gorm_OBJC_FILES = \
@ -235,6 +236,7 @@ Gorm_OBJC_FILES = \
GormViewWithSubviewsEditor.m \
GormWindowEditor.m \
NSColorWell+GormExtensions.m \
NSFontManager+GormExtensions.m \
NSView+GormExtensions.m \
main.m \
Gorm.m

View file

@ -29,6 +29,7 @@
#include <AppKit/AppKit.h>
#include <Foundation/Foundation.h>
#include <GNUstepGUI/GSNibTemplates.h>
#include <InterfaceBuilder/InterfaceBuilder.h>
@class GormClassManager, GormClassEditor, GormObjectProxy, GormFilesOwner;

View file

@ -916,7 +916,8 @@ static NSImage *fileImage = nil;
- (void) dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver: self];
ASSIGN(lastEditor, nil);
// close the window...
[window close];
@ -2960,7 +2961,7 @@ static NSImage *fileImage = nil;
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
NSDebugLog(@"setSelectionFromEditor %@", anEditor);
lastEditor = anEditor;
ASSIGN(lastEditor, anEditor);
[(Gorm *)NSApp stopConnecting]; // cease any connection
if ([(NSObject *)anEditor respondsToSelector: @selector(window)])
{

View file

@ -0,0 +1,34 @@
/* NSFontManager+GormExtensions.h
*
* Copyright (C) 2005 Free Software Foundation, Inc.
*
* Author: Gregory John Casamento <greg_casamento@yahoo.com>
* Date: 2005
*
* This file is part of GNUstep.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef INCLUDED_NSFontManager_GormExtensions_h
#define INCLUDED_NSFontManager_GormExtensions_h
#include <AppKit/NSFontManager.h>
@interface NSFontManager (GormExtensions)
- (BOOL) sendAction;
@end
#endif

View file

@ -0,0 +1,77 @@
/* NSFontManager+GormExtensions.m
*
* Copyright (C) 2004 Free Software Foundation, Inc.
*
* Author: Gregory John Casamento <greg_casamento@yahoo.com>
* Date: 2004
*
* This file is part of GNUstep.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <Foundation/NSObject.h>
#include <Foundation/NSException.h>
#include <AppKit/NSApplication.h>
#include "NSFontManager+GormExtensions.h"
#include "GormDocument.h"
@interface GormDocument (FontManagerMethod)
- (id) lastEditor;
@end
@implementation GormDocument (FontManagerMethod)
- (id) lastEditor
{
return lastEditor;
}
@end
@implementation NSFontManager (GormExtensions)
- (BOOL) sendAction
{
NSApplication *theApp = [NSApplication sharedApplication];
BOOL result = NO;
if (_action)
result = [theApp sendAction: _action to: nil from: self];
if(result == NO)
{
id object = [(GormDocument *)[(id<IB>)NSApp activeDocument] lastEditor];
NS_DURING
{
if(object != nil)
{
if([object respondsToSelector: _action])
{
[object performSelector: _action withObject: self];
result = YES;
}
}
}
NS_HANDLER
{
NSDebugLog(@"Couldn't set font on %@: %@", object, [localException reason]);
result = NO; // just to be sure.
}
NS_ENDHANDLER
}
return result;
}
@end