Refactored NSCell additions out of GormPrivate and added a new method for pboard type registration.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@21148 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2005-04-23 17:16:10 +00:00
parent 91ddcae2a9
commit 9d4a74153b
11 changed files with 217 additions and 85 deletions

View file

@ -1,3 +1,18 @@
2005-04-23 13:11 Gregory John Casamento <greg_casamento@yahoo.com>
* GormCore/GNUmakefile: Added new files.
* GormCore/GormClassEditor.m: Changed to include new header, and
use new method for registration of pboard types.
* GormCode/GormClassEditor.h: New file
* GormCore/GormDocument.m: Changed to include new header.
* GormCore/GormObjectEditor.m: Uses new method to register all
pboard types.
* GormCore/GormPrivate.h: Added declaration for new method.
* GormCore/GormPrivate.m: Added new method to register pboard types.
* GormCore/GormResourceEditor.m: Changed to use new method.
* NSCell+GormAdditions.h: Removed from GormPrivate.h
* NSCell+GormAdditions.m: Removed from GormPrivate.m
2005-04-23 02:50 Gregory John Casamento <greg_casamento@yahoo.com>
* GormCore/GormClassEditor.m: Implementation of editor/dragging

View file

@ -126,6 +126,7 @@ srcdir = .
GormCore_HEADER_FILES = \
GormBoxEditor.h \
GormClassEditor.h \
GormClassInspector.h \
GormClassManager.h \
GormClassPanelController.h \
@ -160,6 +161,7 @@ GormCore_HEADER_FILES = \
GormViewWindow.h \
GormViewWithContentViewEditor.h \
GormViewWithSubviewsEditor.h \
NSCell+GormAdditions.h \
NSColorWell+GormExtensions.h \
NSFontManager+GormExtensions.h \
NSView+GormExtensions.h
@ -209,6 +211,7 @@ GormCore_OBJC_FILES = \
GormViewWithContentViewEditor.m \
GormViewWithSubviewsEditor.m \
GormWindowEditor.m \
NSCell+GormAdditions.m \
NSColorWell+GormExtensions.m \
NSFontManager+GormExtensions.m \
NSView+GormExtensions.m \

View file

@ -0,0 +1,57 @@
/* GormClassEditor.h
*
* Copyright (C) 1999, 2003, 2005 Free Software Foundation, Inc.
*
* Author: Gregory John Casamento <greg_casamento@yahoo.com>
* Date: 1999, 2003, 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_GormClassEditor_h
#define INCLUDED_GormClassEditor_h
#include <InterfaceBuilder/InterfaceBuilder.h>
#include <GormCore/GormOutlineView.h>
@class NSString, NSArray, GormDocument, GormClassManager;
extern NSString *GormClassPboardType;
@interface GormClassEditor : GormOutlineView <IBEditors, IBSelectionOwners>
{
GormDocument *document;
GormClassManager *classManager;
NSString *selectedClass;
}
- (GormClassEditor*) initWithDocument: (GormDocument*)doc;
+ (GormClassEditor*) classEditorForDocument: (GormDocument*)doc;
- (void) setSelectedClassName: (NSString*)cn;
- (NSString *) selectedClassName;
- (void) selectClassWithObject: (id)obj editClass: (BOOL)flag;
- (void) selectClassWithObject: (id)obj;
- (void) selectClass: (NSString *)className editClass: (BOOL)flag;
- (void) selectClass: (NSString *)className;
- (BOOL) currentSelectionIsClass;
- (void) editClass;
- (void) createSubclass;
- (void) addAttributeToClass;
- (void) deleteSelection;
- (NSArray *) fileTypes;
@end
#endif

View file

@ -23,10 +23,14 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "GormPrivate.h"
#include <Foundation/Foundation.h>
#include <AppKit/AppKit.h>
#include "GormClassEditor.h"
#include "GormClassManager.h"
#include "GormFunctions.h"
#include <AppKit/NSPasteboard.h>
#include "GormDocument.h"
#include "GormProtocol.h"
#include "GormPrivate.h"
NSString *GormClassPboardType = @"GormClassPboardType";
@ -52,6 +56,8 @@ NSString *GormClassPboardType = @"GormClassPboardType";
// weak connections...
document = doc;
classManager = [doc classManager];
[IBResourceManager registerForAllPboardTypes: self
inDocument: document];
// set up the outline view...
[self setDataSource: self];
@ -64,8 +70,6 @@ NSString *GormClassPboardType = @"GormClassPboardType";
[self setIndentationPerLevel: 10];
[self setAttributeOffset: 30];
[self setRowHeight: 18];
[self registerForDraggedTypes: [NSArray arrayWithObjects: NSFilenamesPboardType,
GormLinkPboardType, nil]];
[self setMenu: [(id<Gorm>)NSApp classMenu]];
[self setBackgroundColor: salmonColor ];

View file

@ -46,6 +46,7 @@
#include "GormSound.h"
#include "GormImage.h"
#include "GormViewResourceManager.h"
#include "GormClassEditor.h"
@interface GormDisplayCell : NSButtonCell
@end

View file

@ -296,25 +296,6 @@ static NSMapTable *docMap = 0;
{
}
- (void) _registerForAllResourceManagers
{
NSMutableArray *allTypes = [[NSMutableArray alloc] initWithObjects: NSFilenamesPboardType,
GormLinkPboardType, nil];
NSArray *mgrs = [(GormDocument *)document resourceManagers];
NSEnumerator *en = [mgrs objectEnumerator];
IBResourceManager *mgr = nil;
AUTORELEASE(allTypes);
while((mgr = [en nextObject]) != nil)
{
NSArray *pbTypes = [mgr resourcePasteboardTypes];
[allTypes addObjectsFromArray: pbTypes];
}
[self registerForDraggedTypes: allTypes];
}
- (void) handleNotification: (NSNotification*)aNotification
{
NSString *name = [aNotification name];
@ -326,7 +307,8 @@ static NSMapTable *docMap = 0;
}
else if([name isEqual: IBResourceManagerRegistryDidChangeNotification])
{
[self _registerForAllResourceManagers];
[IBResourceManager registerForAllPboardTypes: self
inDocument: document];
}
}
@ -352,9 +334,8 @@ static NSMapTable *docMap = 0;
document = aDocument;
[self _registerForAllResourceManagers];
// [self registerForDraggedTypes: [NSArray arrayWithObjects:
// IBObjectPboardType, GormLinkPboardType, nil]];
[IBResourceManager registerForAllPboardTypes: self
inDocument: document];
[self setAutosizesCells: NO];
[self setCellSize: defaultCellSize()];

View file

@ -26,10 +26,6 @@
#ifndef INCLUDED_GormPrivate_h
#define INCLUDED_GormPrivate_h
@class GormDocument;
@class GormInspectorsManager;
@class GormPalettesManager;
#include <InterfaceBuilder/IBApplicationAdditions.h>
#include <InterfaceBuilder/IBInspector.h>
#include <InterfaceBuilder/IBViewAdditions.h>
@ -49,6 +45,10 @@ extern NSString *GormDidDeleteClassNotification;
extern NSString *GormWillDetachObjectFromDocumentNotification;
extern NSString *GormResizeCellNotification;
@class GormDocument;
@class GormInspectorsManager;
@class GormPalettesManager;
// templates
@interface GSNibItem (GormAdditions)
- initWithClassName: (NSString*)className frame: (NSRect)frame;
@ -82,28 +82,6 @@ extern NSString *GormResizeCellNotification;
- (NSString*) sizeInspectorClassName;
@end
@interface GormClassEditor : GormOutlineView <IBEditors, IBSelectionOwners>
{
GormDocument *document;
GormClassManager *classManager;
NSString *selectedClass;
}
- (GormClassEditor*) initWithDocument: (GormDocument*)doc;
+ (GormClassEditor*) classEditorForDocument: (GormDocument*)doc;
- (void) setSelectedClassName: (NSString*)cn;
- (NSString *) selectedClassName;
- (void) selectClassWithObject: (id)obj editClass: (BOOL)flag;
- (void) selectClassWithObject: (id)obj;
- (void) selectClass: (NSString *)className editClass: (BOOL)flag;
- (void) selectClass: (NSString *)className;
- (BOOL) currentSelectionIsClass;
- (void) editClass;
- (void) createSubclass;
- (void) addAttributeToClass;
- (void) deleteSelection;
- (NSArray *) fileTypes;
@end
@interface GormGenericEditor : NSMatrix <IBEditors, IBSelectionOwners>
{
NSMutableArray *objects;
@ -235,6 +213,11 @@ extern NSString *GormResizeCellNotification;
- (BOOL) illegalClassSubstitution;
@end
@interface IBResourceManager (GormAdditions)
+ (void) registerForAllPboardTypes: (id)editor
inDocument: (id)document;
@end
/*
* Functions for drawing knobs etc.
*/

View file

@ -51,37 +51,7 @@ static BOOL _illegalClassSubstitution = NO;
// we had this include for grouping/ungrouping selectors
#include "GormViewWithContentViewEditor.h"
@implementation NSCell (GormAdditions)
/*
* this methods is directly coming from NSCell.m
* The only additions is [textObject setUsesFontPanel: NO]
* We do this because we want to have control over the font panel changes
*/
- (NSText *)setUpFieldEditorAttributes:(NSText *)textObject
{
[textObject setUsesFontPanel: NO];
[textObject setTextColor: [self textColor]];
if (_cell.contents_is_attributed_string == NO)
{
/* TODO: Manage scrollable attribute */
[textObject setFont: _font];
[textObject setAlignment: _cell.text_align];
}
else
{
/* TODO: What do we do if we are an attributed string.
Think about what happens when the user ends editing.
Allows editing text attributes... Formatter. */
}
[textObject setEditable: _cell.is_editable];
[textObject setSelectable: _cell.is_selectable || _cell.is_editable];
[textObject setRichText: _cell.is_rich_text];
[textObject setImportsGraphics: _cell.imports_graphics];
[textObject setSelectedRange: NSMakeRange(0, 0)];
return textObject;
}
@end
@implementation GSNibItem (GormAdditions)
- initWithClassName: (NSString*)className frame: (NSRect)frame
@ -257,6 +227,28 @@ static BOOL _illegalClassSubstitution = NO;
}
@end
@implementation IBResourceManager (GormAdditions)
+ (void) registerForAllPboardTypes: (id)editor
inDocument: (id)doc
{
NSMutableArray *allTypes = [[NSMutableArray alloc] initWithObjects: NSFilenamesPboardType,
GormLinkPboardType, nil];
NSArray *mgrs = [(GormDocument *)doc resourceManagers];
NSEnumerator *en = [mgrs objectEnumerator];
IBResourceManager *mgr = nil;
AUTORELEASE(allTypes);
while((mgr = [en nextObject]) != nil)
{
NSArray *pbTypes = [mgr resourcePasteboardTypes];
[allTypes addObjectsFromArray: pbTypes];
}
[editor registerForDraggedTypes: allTypes];
}
@end
// these are temporary until the deprecated templates are removed...
////////////////////////////////////////////////////////
// DEPRECATED TEMPLATES //

View file

@ -194,8 +194,9 @@ static int handled_mask= NSDragOperationCopy | NSDragOperationGeneric | NSDragOp
{
NSButtonCell *proto;
[self registerForDraggedTypes: [NSArray arrayWithObjects:
NSFilenamesPboardType, GormLinkPboardType, nil]];
// register for all types.
[IBResourceManager registerForAllPboardTypes: self
inDocument: aDocument];
[self setAutosizesCells: NO];
[self setCellSize: NSMakeSize(72,72)];

View file

@ -0,0 +1,36 @@
/* NSCell+GormAdditions.h
*
* Copyright (C) 1999, 2003, 2005 Free Software Foundation, Inc.
*
* Author: Gregory John Casamento <greg_casamento@yahoo.com>
* Date: 1999, 2003, 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_NSCellGormAdditions_h
#define INCLUDED_NSCellGormAdditions_h
#include <AppKit/NSCell.h>
@class NSText;
@interface NSCell (GormAdditions)
- (NSText *)setUpFieldEditorAttributes:(NSText *)textObject;
@end
#endif

View file

@ -0,0 +1,59 @@
/* NSCell+GormAdditions.h
*
* Copyright (C) 1999, 2003 Free Software Foundation, Inc.
*
* Author: Gregory John Casamento <greg_casamento@yahoo.com>
* Date: 1999, 2003
*
* 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/Foundation.h>
#include <AppKit/NSText.h>
#include "NSCell+GormAdditions.h"
@implementation NSCell (GormAdditions)
/*
* this methods is directly coming from NSCell.m
* The only additions is [textObject setUsesFontPanel: NO]
* We do this because we want to have control over the font panel changes
*/
- (NSText *)setUpFieldEditorAttributes:(NSText *)textObject
{
[textObject setUsesFontPanel: NO];
[textObject setTextColor: [self textColor]];
if (_cell.contents_is_attributed_string == NO)
{
/* TODO: Manage scrollable attribute */
[textObject setFont: _font];
[textObject setAlignment: _cell.text_align];
}
else
{
/* TODO: What do we do if we are an attributed string.
Think about what happens when the user ends editing.
Allows editing text attributes... Formatter. */
}
[textObject setEditable: _cell.is_editable];
[textObject setSelectable: _cell.is_selectable || _cell.is_editable];
[textObject setRichText: _cell.is_rich_text];
[textObject setImportsGraphics: _cell.imports_graphics];
[textObject setSelectedRange: NSMakeRange(0, 0)];
return textObject;
}
@end