New Form, PopUpButton and Cell inspectors

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@11184 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Laurent Julliard 2001-10-17 22:56:17 +00:00
parent 4bff16a055
commit a8b91726da
3 changed files with 405 additions and 4 deletions

View file

@ -1,3 +1,16 @@
2001-10-17 Laurent Julliard <laurent@julliard-online.org>>
* Palettes/2Controls/GormFormInspector.gorm: New Form inspector.
* Palettes/2Controls/GormFormInspector.classes: likewise.
* Palettes/2Controls/GormPopUpButtonInspector.gorm: New PopUp Button inspector
* Palettes/2Controls/GormPopUpButtonInspector.classes: likewise
* Palettes/2Controls/GormCellInspector.gorm: New Cell Inspector
* Palettes/2Controls/GormCellInspector.classes: likewise
* Palettes/2Controls/inspectors.m: new logic for the new inspectors
* Palettes/2Controls/GNUmakefile: new inspectors in resources
2001-10-16 Adam Fedor <fedor@gnu.org> 2001-10-16 Adam Fedor <fedor@gnu.org>
* GormPalettesManager.m ([GormPalettesManager -setCurrentPalette:]): * GormPalettesManager.m ([GormPalettesManager -setCurrentPalette:]):

View file

@ -31,7 +31,10 @@ PALETTE_NAME = 2Controls
2Controls_RESOURCE_FILES = ControlsPalette.tiff \ 2Controls_RESOURCE_FILES = ControlsPalette.tiff \
GormBoxInspector.gorm \ GormBoxInspector.gorm \
GormButtonInspector.gorm \ GormButtonInspector.gorm \
GormCellInspector.gorm \
GormFormInspector.gorm \
GormMatrixInspector.gorm \ GormMatrixInspector.gorm \
GormPopUpButtonInspector.gorm \
GormSliderInspector.gorm \ GormSliderInspector.gorm \
GormStepperInspector.gorm \ GormStepperInspector.gorm \
GormTextFieldInspector.gorm GormTextFieldInspector.gorm

View file

@ -430,17 +430,298 @@
@implementation GormButtonCellAttributesInspector @implementation GormButtonCellAttributesInspector
@end @end
/*----------------------------------------------------------------------------
NSCell
*/
@implementation NSCell (IBInspectorClassNames)
- (NSString*) inspectorClassName
{
return @"GormCellAttributesInspector";
}
@end
@interface GormCellAttributesInspector: IBInspector
{
id disabledSwitch;
id tagForm;
}
@end
@implementation GormCellAttributesInspector
- (void) _setValuesFromControl: control
{
if (control == disabledSwitch)
{
[object setEnabled: ([control state] == NSOffState)];
}
else if (control == tagForm)
{
[object setTag: [[control cellAtRow: 0 column: 0] intValue] ];
}
}
- (void) _getValuesFromObject: anObject
{
if (anObject != object)
return;
[disabledSwitch setState: ([anObject isEnabled]) ? NSOffState : NSOnState];
[[tagForm cellAtRow: 0 column: 0] setIntValue: [anObject tag] ];
}
- (void) controlTextDidEndEditing: (NSNotification*)aNotification
{
id notifier = [aNotification object];
[self _setValuesFromControl: notifier];
}
- (void) dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver: self];
RELEASE(window);
RELEASE(okButton);
[super dealloc];
}
- (id) init
{
if ([super init] == nil)
return nil;
if ([NSBundle loadNibNamed: @"GormCellInspector" owner: self] == NO)
{
NSLog(@"Could not gorm GormCellInspector");
return nil;
}
[[NSNotificationCenter defaultCenter]
addObserver: self
selector: @selector(controlTextDidEndEditing:)
name: NSControlTextDidEndEditingNotification
object: nil];
return self;
}
- (BOOL) wantsButtons
{
return YES;
}
- (NSButton*) okButton
{
if (okButton == nil)
{
okButton = [[NSButton alloc] initWithFrame: NSMakeRect(0,0,90,20)];
[okButton setAutoresizingMask: NSViewMaxYMargin | NSViewMinXMargin];
[okButton setAction: @selector(ok:)];
[okButton setTarget: self];
[okButton setTitle: @"OK"];
[okButton setEnabled: YES];
}
return okButton;
}
- (void) ok: (id)sender
{
[self _setValuesFromControl: disabledSwitch];
[self _setValuesFromControl: tagForm];
}
- (void) setObject: (id)anObject
{
[super setObject: anObject];
[self _getValuesFromObject: anObject];
}
@end
/*---------------------------------------------------------------------------- /*----------------------------------------------------------------------------
NSForm NSForm
*/ */
@implementation NSForm (IBInspectorClassNames) @implementation NSForm (IBInspectorClassNames)
- (NSString*) inspectorClassName - (NSString*) inspectorClassName
{ {
// Not Implemented Yet return @"GormFormAttributesInspector";
return @"GormObjectInspector";
} }
@end @end
@interface GormFormAttributesInspector: IBInspector
{
id backgroundColorWell;
id drawsBackgroundSwitch;
id optionMatrix;
id tagForm;
id textMatrix;
id titleMatrix;
}
@end
@implementation GormFormAttributesInspector
- (void) _setValuesFromControl: control
{
int rows,cols,i;
[object getNumberOfRows: &rows columns: &cols];
if (control == backgroundColorWell)
{
[object setBackgroundColor: [control color]];
}
else if (control == drawsBackgroundSwitch)
{
[object setDrawsBackground: ([control state] == NSOnState)];
}
else if (control == optionMatrix)
{
BOOL flag;
// Cells tags = Positions?
flag = ([[control cellAtRow: 0 column: 0] state] == NSOnState) ? YES : NO;
if (flag == YES) {
for (i=0; i<rows; i++)
[[object cellAtIndex: i] setTag: i];
}
// Editable?
flag = ([[control cellAtRow: 1 column: 0] state] == NSOnState) ? YES : NO;
for (i=0; i<rows; i++)
[[object cellAtIndex: i] setEditable: flag];
// Selectable?
flag = ([[control cellAtRow: 2 column: 0] state] == NSOnState) ? YES : NO;
for (i=0; i<rows; i++)
[[object cellAtIndex: i] setSelectable: flag];
// Scrollable?
flag = ([[control cellAtRow: 3 column: 0] state] == NSOnState) ? YES : NO;
for (i=0; i<rows; i++)
[[object cellAtIndex: i] setScrollable: flag];
}
else if (control == textMatrix)
{
NSLog(@"Tag of selected cell in Text matrix: %d",[[control selectedCell] tag]);
[object setTextAlignment: (NSTextAlignment)[[control selectedCell] tag]];
}
else if (control == titleMatrix)
{
NSLog(@"Tag of selected cell in Title matrix: %d",[[control selectedCell] tag]);
[object setTitleAlignment: (NSTextAlignment)[[control selectedCell] tag]];
}
else if (control == tagForm)
{
[object setTag: [[control cellAtRow: 0 column: 0] intValue] ];
}
}
- (void) _getValuesFromObject: anObject
{
if (anObject != object)
return;
[backgroundColorWell setColor: [anObject backgroundColor] ];
[drawsBackgroundSwitch setState:
([anObject drawsBackground]) ? NSOnState : NSOffState];
[textMatrix selectCellWithTag: [[anObject cellAtIndex: 0] alignment] ];
[titleMatrix selectCellWithTag: [[anObject cellAtIndex: 0] titleAlignment] ];
[optionMatrix deselectAllCells];
if ([[anObject cellAtIndex: 0] isEditable])
[optionMatrix selectCellAtRow: 1 column: 0];
if ([[anObject cellAtIndex: 0] isSelectable])
[optionMatrix selectCellAtRow: 2 column: 0];
if ([[anObject cellAtIndex: 0] isScrollable])
[optionMatrix selectCellAtRow: 3 column: 0];
// Cells tags = position is not directly stored in the Form so guess it.
{
int rows,cols;
[anObject getNumberOfRows: &rows columns: &cols];
if ( (rows > 1) && ([[anObject cellAtIndex: rows-1] tag] == rows-1) )
{
[optionMatrix selectCellAtRow: 0 column: 0];
}
}
[[tagForm cellAtRow: 0 column: 0] setIntValue: [anObject tag] ];
}
- (void) controlTextDidEndEditing: (NSNotification*)aNotification
{
id notifier = [aNotification object];
[self _setValuesFromControl: notifier];
}
- (void) dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver: self];
RELEASE(window);
RELEASE(okButton);
[super dealloc];
}
- (id) init
{
if ([super init] == nil)
return nil;
if ([NSBundle loadNibNamed: @"GormFormInspector" owner: self] == NO)
{
NSLog(@"Could not gorm GormFormInspector");
return nil;
}
[[NSNotificationCenter defaultCenter]
addObserver: self
selector: @selector(controlTextDidEndEditing:)
name: NSControlTextDidEndEditingNotification
object: nil];
return self;
}
- (BOOL) wantsButtons
{
return YES;
}
- (NSButton*) okButton
{
if (okButton == nil)
{
okButton = [[NSButton alloc] initWithFrame: NSMakeRect(0,0,80,30)];
[okButton setAutoresizingMask: NSViewMaxYMargin | NSViewMinXMargin];
[okButton setAction: @selector(ok:)];
[okButton setTarget: self];
[okButton setTitle: @"OK"];
[okButton setEnabled: YES];
}
return okButton;
}
- (void) ok: (id)sender
{
[self _setValuesFromControl: optionMatrix];
[self _setValuesFromControl: backgroundColorWell];
[self _setValuesFromControl: drawsBackgroundSwitch];
[self _setValuesFromControl: textMatrix];
[self _setValuesFromControl: titleMatrix];
[self _setValuesFromControl: tagForm];
}
- (void) setObject: (id)anObject
{
[super setObject: anObject];
[self _getValuesFromObject: anObject];
}
@end
/*---------------------------------------------------------------------------- /*----------------------------------------------------------------------------
NSMatrix NSMatrix
*/ */
@ -570,11 +851,115 @@
@implementation NSPopUpButton (IBInspectorClassNames) @implementation NSPopUpButton (IBInspectorClassNames)
- (NSString*) inspectorClassName - (NSString*) inspectorClassName
{ {
// Not Implemented Yet return @"GormPopUpButtonAttributesInspector";
return @"GormObjectInspector";
} }
@end @end
@interface GormPopUpButtonAttributesInspector : IBInspector
{
id typeMatrix;
id disabledSwitch;
id tagForm;
}
@end
@implementation GormPopUpButtonAttributesInspector
- (void) _setValuesFromControl: control
{
if (control == typeMatrix)
{
[object setPullsDown: [[control selectedCell] tag] ];
}
else if (control == disabledSwitch)
{
[object setAutoenablesItems: ([control state] == NSOffState) ];
}
else if (control == tagForm)
{
[object setTag: [[control cellAtRow: 0 column: 0] intValue] ];
}
}
- (void) _getValuesFromObject: anObject
{
if (anObject != object)
return;
[typeMatrix selectCellWithTag: [anObject pullsDown] ];
[disabledSwitch setState: ![anObject autoenablesItems] ];
[[tagForm cellAtRow: 0 column: 0] setIntValue: [anObject tag] ];
}
- (void) controlTextDidEndEditing: (NSNotification*)aNotification
{
id notifier = [aNotification object];
[self _setValuesFromControl: notifier];
}
- (void) dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver: self];
RELEASE(window);
RELEASE(okButton);
[super dealloc];
}
- (id) init
{
if ([super init] == nil)
return nil;
if ([NSBundle loadNibNamed: @"GormPopUpButtonInspector" owner: self] == NO)
{
NSLog(@"Could not gorm GormPopUpButtonInspector");
return nil;
}
[[NSNotificationCenter defaultCenter]
addObserver: self
selector: @selector(controlTextDidEndEditing:)
name: NSControlTextDidEndEditingNotification
object: nil];
return self;
}
- (BOOL) wantsButtons
{
return YES;
}
- (NSButton*) okButton
{
if (okButton == nil)
{
okButton = [[NSButton alloc] initWithFrame: NSMakeRect(0,0,90,20)];
[okButton setAutoresizingMask: NSViewMaxYMargin | NSViewMinXMargin];
[okButton setAction: @selector(ok:)];
[okButton setTarget: self];
[okButton setTitle: @"OK"];
[okButton setEnabled: YES];
}
return okButton;
}
- (void) ok: (id)sender
{
[self _setValuesFromControl: typeMatrix];
[self _setValuesFromControl: disabledSwitch];
[self _setValuesFromControl: tagForm];
}
- (void) setObject: (id)anObject
{
[super setObject: anObject];
[self _getValuesFromObject: anObject];
}
@end
/*---------------------------------------------------------------------------- /*----------------------------------------------------------------------------
NSSlider NSSlider
*/ */