mirror of
https://github.com/gnustep/apps-gorm.git
synced 2025-02-23 19:51:00 +00:00
Add new inspector for matrix cell size
This commit is contained in:
parent
5d699dd353
commit
01ed525ca7
9 changed files with 205 additions and 1 deletions
|
@ -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.
|
||||
|
|
|
@ -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]);
|
||||
|
|
|
@ -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 \
|
||||
|
|
26
Palettes/2Controls/GormCellSizeInspector.gorm/data.classes
Normal file
26
Palettes/2Controls/GormCellSizeInspector.gorm/data.classes
Normal 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;
|
||||
};
|
||||
}
|
BIN
Palettes/2Controls/GormCellSizeInspector.gorm/data.info
Normal file
BIN
Palettes/2Controls/GormCellSizeInspector.gorm/data.info
Normal file
Binary file not shown.
BIN
Palettes/2Controls/GormCellSizeInspector.gorm/objects.gorm
Normal file
BIN
Palettes/2Controls/GormCellSizeInspector.gorm/objects.gorm
Normal file
Binary file not shown.
38
Palettes/2Controls/GormCellSizeInspector.h
Normal file
38
Palettes/2Controls/GormCellSizeInspector.h
Normal 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
|
124
Palettes/2Controls/GormCellSizeInspector.m
Normal file
124
Palettes/2Controls/GormCellSizeInspector.m
Normal 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
|
|
@ -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];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue