Addition of IBInspectorMode and changes to inspector manager.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@21396 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2005-07-02 20:09:49 +00:00
parent f5c1bcf9e0
commit 3c8628157c
5 changed files with 218 additions and 1 deletions

View file

@ -50,6 +50,7 @@ IBDocuments.h \
IBEditors.h \ IBEditors.h \
IBInspector.h \ IBInspector.h \
IBInspectorManager.h \ IBInspectorManager.h \
IBInspectorMode.h \
IBObjectAdditions.h \ IBObjectAdditions.h \
IBObjectProtocol.h \ IBObjectProtocol.h \
IBPalette.h \ IBPalette.h \
@ -73,6 +74,7 @@ IBDocuments.m \
IBEditors.m \ IBEditors.m \
IBInspector.m \ IBInspector.m \
IBInspectorManager.m \ IBInspectorManager.m \
IBInspectorMode.m \
IBObjectAdditions.m \ IBObjectAdditions.m \
IBPalette.m \ IBPalette.m \
IBResourceManager.m IBResourceManager.m

View file

@ -40,6 +40,7 @@ IB_EXTERN NSString *IBWillInspectWithModeNotification;
{ {
NSMutableArray *modes; NSMutableArray *modes;
id currentMode; id currentMode;
id selectedObject;
} }
/** /**

View file

@ -25,7 +25,10 @@
#include <Foundation/NSObject.h> #include <Foundation/NSObject.h>
#include <Foundation/NSString.h> #include <Foundation/NSString.h>
#include <Foundation/NSDictionary.h> #include <Foundation/NSDictionary.h>
#include <Foundation/NSArray.h>
#include <InterfaceBuilder/IBInspectorManager.h> #include <InterfaceBuilder/IBInspectorManager.h>
#include <InterfaceBuilder/IBInspectorMode.h>
#include <math.h>
static IBInspectorManager *_sharedInspectorManager = nil; static IBInspectorManager *_sharedInspectorManager = nil;
@ -60,6 +63,7 @@ NSString *IBWillInspectWithModeNotification =
if((self = [super init]) != nil) if((self = [super init]) != nil)
{ {
// set the shared instance... // set the shared instance...
modes = [[NSMutableArray alloc] init];
_sharedInspectorManager = self; _sharedInspectorManager = self;
} }
} }
@ -72,6 +76,12 @@ NSString *IBWillInspectWithModeNotification =
return self; return self;
} }
- (void) dealloc
{
RELEASE(modes);
[super dealloc];
}
/** /**
* Add an inspector for a given mode. This allows the addition * Add an inspector for a given mode. This allows the addition
* of inspectors for different aspects of the same object. * of inspectors for different aspects of the same object.
@ -82,6 +92,30 @@ NSString *IBWillInspectWithModeNotification =
inspectorClassName: (NSString *)className inspectorClassName: (NSString *)className
ordering: (float)ord ordering: (float)ord
{ {
IBInspectorMode *mode = [[IBInspectorMode alloc]
initWithIdentifier: ident
forObject: obj
localizedLabel: label
inspectorClassName: className
ordering: ord];
int position = 0;
int count = [modes count];
if(ord == -1)
{
position = count; // last
}
else
{
position = (int)ceil((double)ord);
if(position > count)
{
position = count;
}
}
[modes insertObject: mode
atIndex: position];
} }
/** /**
@ -90,6 +124,19 @@ NSString *IBWillInspectWithModeNotification =
*/ */
- (unsigned int) indexOfModeWithIdentifier: (NSString *)ident - (unsigned int) indexOfModeWithIdentifier: (NSString *)ident
{ {
return 0; NSEnumerator *en = [modes objectEnumerator];
int index = 0;
id mode = nil;
while((mode = [en nextObject]) != nil)
{
if([[mode identifier] isEqualToString: ident])
{
break;
}
index++;
}
return index;
} }
@end @end

57
GormLib/IBInspectorMode.h Normal file
View file

@ -0,0 +1,57 @@
/* IBInspectorMode
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
*/
#ifndef IBINSPECTORMODE_H
#define IBINSPECTORMODE_H
#include <Foundation/NSObject.h>
@class NSString;
@interface IBInspectorMode : NSObject
{
NSString *identifier;
NSString *localizedLabel;
NSString *inspectorClassName;
id object;
float ordering;
}
- (id) initWithIdentifier: (NSString *)ident
forObject: (id)obj
localizedLabel: (NSString *)lab
inspectorClassName: (NSString *)cn
ordering: (float)ord;
- (void) setIdentifier: (NSString *)ident;
- (NSString *) identifier;
- (void) setObject: (id)obj;
- (id) object;
- (void) setLocalizedLabel: (NSString *)label;
- (NSString *) localizedLabel;
- (void) setInspectorClassName: (NSString *)className;
- (NSString *) inspectorClassName;
- (void) setOrdering: (float)ord;
- (float) ordering;
@end
#endif

110
GormLib/IBInspectorMode.m Normal file
View file

@ -0,0 +1,110 @@
/* IBInspectorMode
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
*/
#include <InterfaceBuilder/IBInspectorMode.h>
#include <Foundation/NSArray.h>
#include <Foundation/NSString.h>
/**
* IBInspectorMode is an internal class in the InterfaceBuilder framework.
*/
@implementation IBInspectorMode
- (id) initWithIdentifier: (NSString *)ident
forObject: (id)obj
localizedLabel: (NSString *)lab
inspectorClassName: (NSString *)cn
ordering: (float)ord
{
if((self = [super init]) != nil)
{
[self setIdentifier: ident];
[self setObject: obj];
[self setLocalizedLabel: lab];
[self setInspectorClassName: cn];
[self setOrdering: ord];
}
return self;
}
- (void) dealloc
{
RELEASE(identifier);
// RELEASE(object);
RELEASE(localizedLabel);
RELEASE(inspectorClassName);
[super dealloc];
}
- (void) setIdentifier: (NSString *)ident
{
ASSIGN(identifier, ident);
}
- (NSString *) identifier
{
return identifier;
}
- (void) setObject: (id)obj
{
// don't retain the object, since we are not the owner.
object = obj;
}
- (id) object
{
return object;
}
- (void) setLocalizedLabel: (NSString *)lab
{
ASSIGN(localizedLabel, lab);
}
- (NSString *) localizedLabel
{
return localizedLabel;
}
- (void) setInspectorClassName: (NSString *)cn
{
ASSIGN(inspectorClassName, cn);
}
- (NSString *) inspectorClassName
{
return inspectorClassName;
}
- (void) setOrdering: (float)ord
{
ordering = ord;
}
- (float) ordering
{
return ordering;
}
@end