Add new inspector for matrix cell size

This commit is contained in:
Gregory John Casamento 2021-03-28 01:34:15 -04:00
parent 5d699dd353
commit 01ed525ca7
9 changed files with 205 additions and 1 deletions

View file

@ -541,6 +541,13 @@ static NSImage *fileImage = nil;
NSArray *old;
BOOL newObject = NO;
if ([self containsObject: anObject] &&
[anObject isKindOfClass: [NSWindow class]] == NO &&
[anObject isKindOfClass: [NSPanel class]] == NO)
{
return;
}
// Modify the document whenever something is added...
[self touch];
@ -751,6 +758,7 @@ static NSImage *fileImage = nil;
{
// add all of the cells....
[self attachObjects: [anObject cells] toParent: anObject];
[self attachObject: [anObject prototype] toParent: anObject];
}
/*
* If it's a simple NSView, add it and all of it's subviews.

View file

@ -77,7 +77,9 @@
- (void) willInspectObject: (NSNotification *)notification
{
id o = [notification object];
if ([o respondsToSelector: @selector(prototype)] && [o prototype])
// [o respondsToSelector: @selector(prototype)] && [o prototype])
if ([o isKindOfClass: [NSMatrix class]])
{
id prototype = [o prototype];
NSString *ident = NSStringFromClass([prototype class]);

View file

@ -31,6 +31,7 @@ PALETTE_NAME = 2Controls
GormButtonAttributesInspector.m \
GormBoxAttributesInspector.m \
GormCellAttributesInspector.m \
GormCellSizeInspector.m \
GormColorWellAttributesInspector.m \
GormFormAttributesInspector.m \
GormPopUpButtonAttributesInspector.m \
@ -51,6 +52,7 @@ PALETTE_NAME = 2Controls
GormNSBoxInspector.gorm \
GormNSButtonInspector.gorm \
GormNSCellInspector.gorm \
GormCellSizeInspector.gorm \
GormNSFormInspector.gorm \
GormNSMatrixInspector.gorm \
GormNSPopUpButtonInspector.gorm \

View file

@ -0,0 +1,26 @@
{
"## Comment" = "Do NOT change this file, Gorm maintains it";
FirstResponder = {
Actions = (
"revert:",
"setObject:",
"touch:"
);
Super = NSObject;
};
GormCellSizeInspector = {
Actions = (
);
Outlets = (
width,
height
);
Super = IBInspector;
};
IBInspector = {
Actions = (
"setObject:"
);
Super = NSObject;
};
}

View file

@ -0,0 +1,38 @@
/* GormViewSizeInspector.m
*
* Copyright (C) 2021 Free Software Foundation, Inc.
*
* Author: Gregory John Casamento <greg.casamento@gmail.com
* Separated out into header.
* Date: 2021
*
* 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 3 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 INCLUDED_GormCellSizeInspector_h
#define INCLUDED_GormCellSizeInspector_h
#include <InterfaceBuilder/InterfaceBuilder.h>
@interface GormCellSizeInspector : IBInspector
{
NSTextField *width;
NSTextField *height;
}
@end
#endif

View file

@ -0,0 +1,124 @@
/* GormCellSizeInspector.m
*
* Copyright (C) 2021 Free Software Foundation, Inc.
*
* Author: Gregory Casamento <greg.casamento@gmail.com>
* Date: 2021
*
* 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 3 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/InterfaceBuilder.h>
#include "GormCellSizeInspector.h"
@implementation NSCell (IBObjectAdditions)
- (NSString *) sizeInspectorClassName
{
return @"GormCellSizeInspector";
}
@end
@implementation GormCellSizeInspector
+ (void) initialize
{
if (self == [GormCellSizeInspector class])
{
}
}
- (void) dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver: self];
RELEASE(window);
[super dealloc];
}
- (id) init
{
self = [super init];
if (self != nil)
{
if ([NSBundle loadNibNamed: @"GormCellSizeInspector"
owner: self] == NO)
{
NSLog(@"Could not open gorm GormViewSizeInspector");
NSLog(@"self %@", self);
return nil;
}
[[NSNotificationCenter defaultCenter]
addObserver: self
selector: @selector(controlTextDidEndEditing:)
name: NSControlTextDidEndEditingNotification
object: nil];
}
return self;
}
- (void) ok: (id)sender
{
id<IBDocuments> document = [(id<IB>)NSApp activeDocument];
id parent = [document parentOfObject: object];
if ([parent respondsToSelector: @selector(cellSize)])
{
NSSize size;
CGFloat w = [width doubleValue];
CGFloat h = [height doubleValue];
size.width = w;
size.height = h;
[parent setCellSize: size];
[parent sizeToCells];
[parent setNeedsDisplay: YES];
// Update the document as edited...
[document touch];
}
}
- (void) revert: (id)sender
{
NSLog(@"sender = %@",sender);
}
- (void) controlTextDidEndEditing: (NSNotification*)aNotification
{
id obj = [aNotification object];
[super ok: obj];
}
- (void) setObject: (id)anObject
{
if (anObject != nil && anObject != object)
{
id<IBDocuments> document = [(id<IB>)NSApp activeDocument];
id parent = [document parentOfObject: anObject];
ASSIGN(object, anObject);
if ([parent respondsToSelector: @selector(cellSize)])
{
NSSize size = [parent cellSize];
[width setDoubleValue: size.width];
[height setDoubleValue: size.height];
}
}
}
@end

View file

@ -104,6 +104,7 @@ NSUInteger colsStepperValue;
/* Commit changes that the user makes in the Attributes Inspector */
- (void) ok: (id) sender
{
id<IBDocuments> document = [(id<IB>)NSApp activeDocument];
if (sender == autosizeSwitch)
{
[object setAutosizesCells: ([sender state] == NSOnState)];
@ -263,6 +264,9 @@ NSUInteger colsStepperValue;
{
[prototypeMatrix putCell: [object prototype] atRow:0 column:0];
}
// [document detachObjects: [object cells]];
[document attachObjects: [object cells] toParent: object];
[super ok:sender];
}