diff --git a/ChangeLog b/ChangeLog index 133131c3..8462a0f7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2001-10-17 Laurent Julliard > + + * 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 * GormPalettesManager.m ([GormPalettesManager -setCurrentPalette:]): diff --git a/Palettes/2Controls/GNUmakefile b/Palettes/2Controls/GNUmakefile index 6b37d4a1..21de40a5 100644 --- a/Palettes/2Controls/GNUmakefile +++ b/Palettes/2Controls/GNUmakefile @@ -31,7 +31,10 @@ PALETTE_NAME = 2Controls 2Controls_RESOURCE_FILES = ControlsPalette.tiff \ GormBoxInspector.gorm \ GormButtonInspector.gorm \ + GormCellInspector.gorm \ + GormFormInspector.gorm \ GormMatrixInspector.gorm \ + GormPopUpButtonInspector.gorm \ GormSliderInspector.gorm \ GormStepperInspector.gorm \ GormTextFieldInspector.gorm diff --git a/Palettes/2Controls/inspectors.m b/Palettes/2Controls/inspectors.m index 447884e0..6ad08720 100644 --- a/Palettes/2Controls/inspectors.m +++ b/Palettes/2Controls/inspectors.m @@ -430,17 +430,298 @@ @implementation GormButtonCellAttributesInspector @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 */ @implementation NSForm (IBInspectorClassNames) - (NSString*) inspectorClassName { - // Not Implemented Yet - return @"GormObjectInspector"; + return @"GormFormAttributesInspector"; } @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 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 */ @@ -570,11 +851,115 @@ @implementation NSPopUpButton (IBInspectorClassNames) - (NSString*) inspectorClassName { - // Not Implemented Yet - return @"GormObjectInspector"; + return @"GormPopUpButtonAttributesInspector"; } @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 */