mirror of
https://github.com/gnustep/apps-gorm.git
synced 2025-02-24 03:51:22 +00:00
improvments to palette loading.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@21115 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
0ef62e3d93
commit
aef0f307df
12 changed files with 217 additions and 81 deletions
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
||||||
|
2005-04-16 17:21 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||||
|
|
||||||
|
* GormCore/GormClassManager.m: Added code in initWithDocument:
|
||||||
|
to add the actions to the FirstResponder.
|
||||||
|
* GormCore/GormFunctions.h
|
||||||
|
* GormCore/GormFunctions.m: Added function to get the
|
||||||
|
actions from a class.
|
||||||
|
* GormCore/GormPalettesManager.m: Added code to get
|
||||||
|
actions/outlets from classes in exported from palettes.
|
||||||
|
* Palettes/0Menus/GNUmakefile
|
||||||
|
* Palettes/1Windows/GNUmakefile
|
||||||
|
* Palettes/2Controls/palette.table
|
||||||
|
* Palettes/3Containers/GNUmakefile: Added palette.table
|
||||||
|
|
||||||
2005-04-15 02:14 Gregory John Casamento <greg_casamento@yahoo.com>
|
2005-04-15 02:14 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||||
|
|
||||||
* GormCore/GormInspectorsManager.m: Patch from Matt Rice to
|
* GormCore/GormInspectorsManager.m: Patch from Matt Rice to
|
||||||
|
|
|
@ -112,6 +112,9 @@
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GormPalettesManager *palettesManager = [(id<Gorm>)NSApp palettesManager];
|
GormPalettesManager *palettesManager = [(id<Gorm>)NSApp palettesManager];
|
||||||
|
NSDictionary *importedClasses = [palettesManager importedClasses];
|
||||||
|
NSEnumerator *en = [importedClasses objectEnumerator];
|
||||||
|
NSDictionary *description = nil;
|
||||||
|
|
||||||
// load the classes, initialize the custom class array and map..
|
// load the classes, initialize the custom class array and map..
|
||||||
[self loadFromFile: path];
|
[self loadFromFile: path];
|
||||||
|
@ -120,7 +123,22 @@
|
||||||
categoryClasses = [[NSMutableArray alloc] initWithCapacity: 1];
|
categoryClasses = [[NSMutableArray alloc] initWithCapacity: 1];
|
||||||
|
|
||||||
// add the imported classes to the class information list...
|
// add the imported classes to the class information list...
|
||||||
[classInformation addEntriesFromDictionary: [palettesManager importedClasses]];
|
[classInformation addEntriesFromDictionary: importedClasses];
|
||||||
|
|
||||||
|
// add all of the actions to the FirstResponder
|
||||||
|
while((description = [en nextObject]) != nil)
|
||||||
|
{
|
||||||
|
NSArray *actions = [description objectForKey: @"Actions"];
|
||||||
|
NSEnumerator *aen = [actions objectEnumerator];
|
||||||
|
NSString *actionName = nil;
|
||||||
|
|
||||||
|
// add the actions to the first responder...
|
||||||
|
while((actionName = [aen nextObject]) != nil)
|
||||||
|
{
|
||||||
|
[self addAction: actionName forClassNamed: @"FirstResponder"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,4 +76,8 @@ NSString *formatAction(NSString *action);
|
||||||
// format an outlet
|
// format an outlet
|
||||||
NSString *formatOutlet(NSString *outlet);
|
NSString *formatOutlet(NSString *outlet);
|
||||||
|
|
||||||
|
// get information about class.
|
||||||
|
NSArray *_GSObjCMethodNamesForClass(Class class, BOOL collect);
|
||||||
|
|
||||||
|
NSArray *_GSObjCVariableNames(Class class, BOOL collect);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -339,3 +339,111 @@ NSString *formatOutlet(NSString *outlet)
|
||||||
NSString *identifier = identifierString(outlet);
|
NSString *identifier = identifierString(outlet);
|
||||||
return identifier;
|
return identifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method returns an array listing the names of all the
|
||||||
|
* instance methods available to obj, whether they
|
||||||
|
* belong to the class of obj or one of its superclasses.<br />
|
||||||
|
* If obj is a class, this returns the class methods.<br />
|
||||||
|
* Returns nil if obj is nil.
|
||||||
|
*/
|
||||||
|
NSArray *_GSObjCMethodNamesForClass(Class class, BOOL collect)
|
||||||
|
{
|
||||||
|
NSMutableSet *set;
|
||||||
|
NSArray *array;
|
||||||
|
GSMethodList methods;
|
||||||
|
|
||||||
|
if (class == nil)
|
||||||
|
{
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Add names to a set so methods declared in superclasses
|
||||||
|
* and then overridden do not appear more than once.
|
||||||
|
*/
|
||||||
|
set = [[NSMutableSet alloc] initWithCapacity: 32];
|
||||||
|
while (class != nil)
|
||||||
|
{
|
||||||
|
void *iterator = 0;
|
||||||
|
|
||||||
|
while ((methods = class_nextMethodList(class, &iterator)))
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < methods->method_count; i++)
|
||||||
|
{
|
||||||
|
GSMethod method = &methods->method_list[i];
|
||||||
|
|
||||||
|
if (method->method_name != 0)
|
||||||
|
{
|
||||||
|
NSString *name;
|
||||||
|
const char *cName;
|
||||||
|
|
||||||
|
cName = GSNameFromSelector(method->method_name);
|
||||||
|
name = [[NSString alloc] initWithUTF8String: cName];
|
||||||
|
[set addObject: name];
|
||||||
|
RELEASE(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if we should collect all of the superclass methods, then iterate
|
||||||
|
// up the chain.
|
||||||
|
if(collect)
|
||||||
|
{
|
||||||
|
class = class->super_class;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
class = nil;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
array = [set allObjects];
|
||||||
|
RELEASE(set);
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method returns an array listing the names of all the
|
||||||
|
* instance variables present in the instance obj, whether they
|
||||||
|
* belong to the class of obj or one of its superclasses.<br />
|
||||||
|
* Returns nil if obj is nil.
|
||||||
|
*/
|
||||||
|
NSArray *_GSObjCVariableNames(Class class, BOOL collect)
|
||||||
|
{
|
||||||
|
NSMutableArray *array;
|
||||||
|
struct objc_ivar_list *ivars;
|
||||||
|
|
||||||
|
array = [NSMutableArray arrayWithCapacity: 16];
|
||||||
|
while (class != nil)
|
||||||
|
{
|
||||||
|
ivars = class->ivars;
|
||||||
|
if (ivars != 0)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < ivars->ivar_count; i++)
|
||||||
|
{
|
||||||
|
NSString *name;
|
||||||
|
|
||||||
|
name = [[NSString alloc] initWithUTF8String:
|
||||||
|
ivars->ivar_list[i].ivar_name];
|
||||||
|
[array addObject: name];
|
||||||
|
RELEASE(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if we should collect all of the superclass methods, then iterate
|
||||||
|
// up the chain.
|
||||||
|
if(collect)
|
||||||
|
{
|
||||||
|
class = class->super_class;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
class = nil;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
|
@ -29,75 +29,11 @@
|
||||||
#include <AppKit/NSImage.h>
|
#include <AppKit/NSImage.h>
|
||||||
#include <AppKit/NSSound.h>
|
#include <AppKit/NSSound.h>
|
||||||
#include <GNUstepBase/GSObjCRuntime.h>
|
#include <GNUstepBase/GSObjCRuntime.h>
|
||||||
|
#include "GormFunctions.h"
|
||||||
|
|
||||||
#define BUILTIN_PALETTES @"BuiltinPalettes"
|
#define BUILTIN_PALETTES @"BuiltinPalettes"
|
||||||
#define USER_PALETTES @"UserPalettes"
|
#define USER_PALETTES @"UserPalettes"
|
||||||
|
|
||||||
/**
|
|
||||||
* This method returns an array listing the names of all the
|
|
||||||
* instance methods available to obj, whether they
|
|
||||||
* belong to the class of obj or one of its superclasses.<br />
|
|
||||||
* If obj is a class, this returns the class methods.<br />
|
|
||||||
* Returns nil if obj is nil.
|
|
||||||
*/
|
|
||||||
NSArray *
|
|
||||||
GSObjCMethodNamesForClass(Class class, BOOL collect)
|
|
||||||
{
|
|
||||||
NSMutableSet *set;
|
|
||||||
NSArray *array;
|
|
||||||
GSMethodList methods;
|
|
||||||
|
|
||||||
if (class == nil)
|
|
||||||
{
|
|
||||||
return nil;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* Add names to a set so methods declared in superclasses
|
|
||||||
* and then overridden do not appear more than once.
|
|
||||||
*/
|
|
||||||
set = [[NSMutableSet alloc] initWithCapacity: 32];
|
|
||||||
while (class != nil)
|
|
||||||
{
|
|
||||||
void *iterator = 0;
|
|
||||||
|
|
||||||
while ((methods = class_nextMethodList(class, &iterator)))
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < methods->method_count; i++)
|
|
||||||
{
|
|
||||||
GSMethod method = &methods->method_list[i];
|
|
||||||
|
|
||||||
if (method->method_name != 0)
|
|
||||||
{
|
|
||||||
NSString *name;
|
|
||||||
const char *cName;
|
|
||||||
|
|
||||||
cName = GSNameFromSelector(method->method_name);
|
|
||||||
name = [[NSString alloc] initWithUTF8String: cName];
|
|
||||||
[set addObject: name];
|
|
||||||
RELEASE(name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// if we should collect all of the superclass methods, then iterate
|
|
||||||
// up the chain.
|
|
||||||
if(collect)
|
|
||||||
{
|
|
||||||
class = class->super_class;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
class = nil;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
array = [set allObjects];
|
|
||||||
RELEASE(set);
|
|
||||||
return array;
|
|
||||||
}
|
|
||||||
|
|
||||||
@interface GormPalettePanel : NSPanel
|
@interface GormPalettePanel : NSPanel
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@ -683,13 +619,12 @@ static NSImage *dragImage = nil;
|
||||||
|
|
||||||
- (NSMutableArray *) actionsForClass: (Class) cls
|
- (NSMutableArray *) actionsForClass: (Class) cls
|
||||||
{
|
{
|
||||||
NSArray *methodArray = GSObjCMethodNamesForClass(cls, NO);
|
NSArray *methodArray = _GSObjCMethodNamesForClass(cls, NO);
|
||||||
NSEnumerator *en = [methodArray objectEnumerator];
|
NSEnumerator *en = [methodArray objectEnumerator];
|
||||||
NSMethodSignature *actionSig = [NSMethodSignature signatureWithObjCTypes: "v12@0:4@8"];
|
NSMethodSignature *actionSig = [NSMethodSignature signatureWithObjCTypes: "v12@0:4@8"];
|
||||||
NSMutableArray *actionsArray = [NSMutableArray array];
|
NSMutableArray *actionsArray = [NSMutableArray array];
|
||||||
NSString *methodName = nil;
|
NSString *methodName = nil;
|
||||||
|
NSRange setRange = NSMakeRange(0,3);
|
||||||
NSDebugLog(@"######## class = %@, %@", NSStringFromClass(cls), methodArray);
|
|
||||||
|
|
||||||
while((methodName = [en nextObject]) != nil)
|
while((methodName = [en nextObject]) != nil)
|
||||||
{
|
{
|
||||||
|
@ -697,25 +632,44 @@ static NSImage *dragImage = nil;
|
||||||
NSMethodSignature *signature = [cls instanceMethodSignatureForSelector: sel];
|
NSMethodSignature *signature = [cls instanceMethodSignatureForSelector: sel];
|
||||||
if([signature numberOfArguments] == 3)
|
if([signature numberOfArguments] == 3)
|
||||||
{
|
{
|
||||||
NSDebugLog(@"methodName = %@",methodName);
|
if([actionSig isEqual: signature] && NSEqualRanges([methodName rangeOfString: @"set"], setRange) == NO)
|
||||||
NSDebugLog(@"returnType = %s, %s",[signature methodReturnType], @encode(id));
|
|
||||||
NSDebugLog(@"firstArgument = %s",[signature getArgumentTypeAtIndex: 2]);
|
|
||||||
|
|
||||||
if([actionSig isEqual: signature])
|
|
||||||
{
|
{
|
||||||
NSDebugLog(@"Matches");
|
|
||||||
[actionsArray addObject: methodName];
|
[actionsArray addObject: methodName];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NSDebugLog(@"#######");
|
|
||||||
return actionsArray;
|
return actionsArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSMutableArray *) outletsForClass: (Class) cls
|
- (NSMutableArray *) outletsForClass: (Class) cls
|
||||||
{
|
{
|
||||||
return nil;
|
NSArray *methodArray = _GSObjCMethodNamesForClass(cls, NO);
|
||||||
|
NSEnumerator *en = [methodArray objectEnumerator];
|
||||||
|
NSMethodSignature *outletSig = [NSMethodSignature signatureWithObjCTypes: "v12@0:4@8"];
|
||||||
|
NSMutableArray *outletsArray = [NSMutableArray array];
|
||||||
|
NSString *methodName = nil;
|
||||||
|
NSRange setRange = NSMakeRange(0,3);
|
||||||
|
|
||||||
|
while((methodName = [en nextObject]) != nil)
|
||||||
|
{
|
||||||
|
SEL sel = NSSelectorFromString(methodName);
|
||||||
|
NSMethodSignature *signature = [cls instanceMethodSignatureForSelector: sel];
|
||||||
|
if([signature numberOfArguments] == 3)
|
||||||
|
{
|
||||||
|
if([outletSig isEqual: signature] && NSEqualRanges([methodName rangeOfString: @"set"], setRange) == YES)
|
||||||
|
{
|
||||||
|
NSRange range = NSMakeRange(3,([methodName length] - 4));
|
||||||
|
NSString *outletMethod = [[methodName substringWithRange: range] lowercaseString];
|
||||||
|
if([methodArray containsObject: outletMethod])
|
||||||
|
{
|
||||||
|
[outletsArray addObject: outletMethod];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return outletsArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) importClasses: (NSArray *)classes withDictionary: (NSDictionary *)dict
|
- (void) importClasses: (NSArray *)classes withDictionary: (NSDictionary *)dict
|
||||||
|
|
|
@ -35,7 +35,8 @@ PALETTE_NAME = 0Menus
|
||||||
0Menus_RESOURCE_FILES = MenusPalette.tiff \
|
0Menus_RESOURCE_FILES = MenusPalette.tiff \
|
||||||
GormMenuDrag.tiff \
|
GormMenuDrag.tiff \
|
||||||
GormMenuAttributesInspector.gorm \
|
GormMenuAttributesInspector.gorm \
|
||||||
GormMenuItemAttributesInspector.gorm
|
GormMenuItemAttributesInspector.gorm \
|
||||||
|
palette.table
|
||||||
|
|
||||||
0Menus_STANDARD_INSTALL = no
|
0Menus_STANDARD_INSTALL = no
|
||||||
|
|
||||||
|
|
8
Palettes/0Menus/palette.table
Normal file
8
Palettes/0Menus/palette.table
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
NibFile = "";
|
||||||
|
Class = "MenusPalette";
|
||||||
|
Icon = "MenusPalette";
|
||||||
|
SubstituteClasses = {
|
||||||
|
GormNSMenu = NSMenu;
|
||||||
|
};
|
||||||
|
}
|
|
@ -28,9 +28,12 @@ PALETTE_NAME = 1Windows
|
||||||
1Windows_OBJC_FILES = main.m GormNSWindow.m GormNSPanel.m
|
1Windows_OBJC_FILES = main.m GormNSWindow.m GormNSPanel.m
|
||||||
1Windows_HEADER_FILES = GormNSWindow.h GormNSPanel.h
|
1Windows_HEADER_FILES = GormNSWindow.h GormNSPanel.h
|
||||||
1Windows_PRINCIPAL_CLASS = WindowsPalette
|
1Windows_PRINCIPAL_CLASS = WindowsPalette
|
||||||
1Windows_RESOURCE_FILES = WindowsPalette.tiff WindowDrag.tiff \
|
1Windows_RESOURCE_FILES = \
|
||||||
|
WindowsPalette.tiff \
|
||||||
|
WindowDrag.tiff \
|
||||||
GormNSWindowSizeInspector.gorm \
|
GormNSWindowSizeInspector.gorm \
|
||||||
GormNSWindowInspector.gorm
|
GormNSWindowInspector.gorm \
|
||||||
|
palette.table
|
||||||
|
|
||||||
1Windows_STANDARD_INSTALL = no
|
1Windows_STANDARD_INSTALL = no
|
||||||
|
|
||||||
|
|
10
Palettes/1Windows/palette.table
Normal file
10
Palettes/1Windows/palette.table
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
NOTE = "Automatically generated, do not edit!";
|
||||||
|
NibFile = "";
|
||||||
|
Class = "WindowsPalette";
|
||||||
|
Icon = "WindowsPalette";
|
||||||
|
SubstituteClasses = {
|
||||||
|
GormNSWindow = NSWindow;
|
||||||
|
GormNSPanel = NSPanel;
|
||||||
|
};
|
||||||
|
}
|
|
@ -4,4 +4,8 @@
|
||||||
Icon = "ControlsPalette";
|
Icon = "ControlsPalette";
|
||||||
ExportClasses = ();
|
ExportClasses = ();
|
||||||
ExportImages = ();
|
ExportImages = ();
|
||||||
|
SubstituteClasses = {
|
||||||
|
GormNSPopUpButton = NSPopUpButton;
|
||||||
|
GormNSPopUpButtonCell = NSPopUpButtonCell;
|
||||||
|
};
|
||||||
}
|
}
|
|
@ -48,7 +48,8 @@ PALETTE_NAME = 3Containers
|
||||||
GormNSTableViewInspector.gorm \
|
GormNSTableViewInspector.gorm \
|
||||||
GormNSTableColumnInspector.gorm \
|
GormNSTableColumnInspector.gorm \
|
||||||
GormNSTableColumnSizeInspector.gorm \
|
GormNSTableColumnSizeInspector.gorm \
|
||||||
GormTabViewInspector.gorm
|
GormTabViewInspector.gorm \
|
||||||
|
palette.table
|
||||||
|
|
||||||
3Containers_STANDARD_INSTALL = no
|
3Containers_STANDARD_INSTALL = no
|
||||||
|
|
||||||
|
|
11
Palettes/3Containers/palette.table
Normal file
11
Palettes/3Containers/palette.table
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
NOTE = "Automatically generated, do not edit!";
|
||||||
|
NibFile = "";
|
||||||
|
Class = "ContainersPalette";
|
||||||
|
Icon = "ContainersPalette";
|
||||||
|
SubstituteClasses = {
|
||||||
|
GormNSBrowser = NSBrowser;
|
||||||
|
GormNSTableView = NSTableView;
|
||||||
|
GormNSOutlineView = NSOutlineView;
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue