This commit is contained in:
Gregory Casamento 2025-03-10 19:06:31 +06:00 committed by GitHub
commit 4b7365bdce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 715 additions and 2 deletions

View file

@ -32,7 +32,9 @@ SUBPROJECTS = \
1Windows \
2Controls \
3Containers \
4Data
4Data \
5Formatters \
6GridStack
-include GNUmakefile.preamble

View file

@ -260,7 +260,6 @@
NSMutableArray = {Super = NSArray; };
NSMutableDictionary = {Super = NSDictionary; };
NSNumberFormatter = {Super = NSFormatter; };
NSObject = {};
NSOpenGLView = {Super = NSView; };
NSOutlineView = {Super = NSTableView; };
NSPanel = {Super = NSWindow; };
@ -420,4 +419,20 @@
Outlets = ();
Super = NSArrayController;
};
Object = {};
};
NSDatePicker = {
Super = NSControl;
};
NSPathControl = {
Super = NSControl;
};
NSGridView = {
Super = NSView;
};
NSSwitch = {
Super = NSControl;
};
NSObject = {};
Object = {};
}

View file

@ -0,0 +1,66 @@
/* DataPalette - Formatter Additions...
Copyright (C) 2021 Free Software Foundation, Inc.
Author: Gregory Casamento <greg.casamento@gmail.com>
Date: June 1 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_FormattersPalette_h
#define INCLUDED_FormattersPalette_h
#include <Foundation/Foundation.h>
#include <InterfaceBuilder/InterfaceBuilder.h>
/*
* NSDateFormatter and NSNumberFormatter extensions
* for Gorm Formatters used in the Data Palette
*/
@interface NSDateFormatter (GormAdditions)
+ (int) formatCount;
+ (NSString *) formatAtIndex: (int)index;
+ (NSInteger) indexOfFormat: (NSString *) format;
+ (NSString *) defaultFormat;
+ (id) defaultFormatValue;
@end
@interface NSNumberFormatter (GormAdditions)
+ (int) formatCount;
+ (NSString *) formatAtIndex: (int)index;
+ (NSString *) positiveFormatAtIndex: (int)index;
+ (NSString *) zeroFormatAtIndex: (int)index;
+ (NSString *) negativeFormatAtIndex: (int)index;
+ (NSDecimalNumber *) positiveValueAtIndex: (int)index;
+ (NSDecimalNumber *) negativeValueAtIndex: (int)index;
+ (NSInteger) indexOfFormat: (NSString *)format;
+ (NSString *) defaultFormat;
+ (id) defaultFormatValue;
- (NSString *) zeroFormat;
@end
@interface FormattersPalette: IBPalette <IBViewResourceDraggingDelegates>
@end
#endif

View file

@ -0,0 +1,234 @@
/* FormattersPalette.m
Copyright (C) 2021 Free Software Foundation, Inc.
Author: Gregory Casamento <greg.casamento@gmail.com>
Date: Jun 4 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.
*/
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
#import <Foundation/NSByteCountFormatter.h>
#import <InterfaceBuilder/InterfaceBuilder.h>
#import "FormattersPalette.h"
/* -----------------------------------------------------------
* Some additions to the Formatters Classes specific to Gorm
* -----------------------------------------------------------*/
NSArray *predefinedNumberFormats;
int defaultNumberFormatIndex = 0;
@implementation FormattersPalette
- (id) init
{
if((self = [super init]) != nil)
{
// Make ourselves a delegate, so that when the formatter is dragged in,
// this code is called...
[NSView registerViewResourceDraggingDelegate: self];
// subscribe to the notification...
[[NSNotificationCenter defaultCenter]
addObserver: self
selector: @selector(willInspectObject:)
name: IBWillInspectObjectNotification
object: nil];
}
return self;
}
- (void) dealloc
{
[NSView unregisterViewResourceDraggingDelegate: self];
[[NSNotificationCenter defaultCenter] removeObserver: self];
[super dealloc];
}
- (void) placeFormatter: (NSFormatter *)fm
withImageNamed: (NSString *)imageName
atRect: (NSRect)frame
inView: (NSView *)contents
toolTip: (NSString *)tooltip
{
id v;
NSImage *img;
NSString *path = [[NSBundle bundleForClass: [self class]]
pathForImageResource: imageName];
img = [[NSImage alloc] initWithContentsOfFile: path];
v = [[NSImageView alloc] initWithFrame: frame];
[v setImageFrameStyle: NSImageFramePhoto];
[v setImageScaling: NSScaleProportionally];
[v setImageAlignment: NSImageAlignCenter];
[v setImage: img];
[v setToolTip: tooltip];
[contents addSubview: v];
[self associateObject: fm type: IBFormatterPboardType with: v];
RELEASE(v);
RELEASE(img);
}
- (void) finishInstantiate
{
NSView *contents;
originalWindow = [[NSWindow alloc] initWithContentRect:
NSMakeRect(0, 0, 272, 192)
styleMask: NSBorderlessWindowMask
backing: NSBackingStoreRetained
defer: NO];
[originalWindow setTitle: @"Formatters"];
contents = [originalWindow contentView];
/* Formatters. */
[self placeFormatter: [[NSByteCountFormatter alloc] init]
withImageNamed: @"bytecount_formatter"
atRect: NSMakeRect(192, 48, 43, 43)
inView: contents
toolTip: @"Byte Count"];
[self placeFormatter: [[NSDateComponentsFormatter alloc] init]
withImageNamed: @"date_comp_formatter"
atRect: NSMakeRect(144, 48, 43, 43)
inView: contents
toolTip: @"Date Components"];
[self placeFormatter: [[NSDateIntervalFormatter alloc] init]
withImageNamed: @"date_interval_formatter"
atRect: NSMakeRect(96, 48, 43, 43)
inView: contents
toolTip: @"Date Interval"];
[self placeFormatter: [[NSPersonNameComponentsFormatter alloc] init]
withImageNamed: @"energy_formatter"
atRect: NSMakeRect(48, 48, 43, 43)
inView: contents
toolTip: @"Energy"];
[self placeFormatter: [[NSMeasurementFormatter alloc] init]
withImageNamed: @"measurement_formatter"
atRect: NSMakeRect(0, 48, 43, 43)
inView: contents
toolTip: @"Measurement"];
[self placeFormatter: [[NSLengthFormatter alloc] init]
withImageNamed: @"length_formatter"
atRect: NSMakeRect(0, 96, 43, 43)
inView: contents
toolTip: @"Length"];
}
- (void) willInspectObject: (NSNotification *)notification
{
id o = [notification object];
if([o respondsToSelector: @selector(cell)])
{
id cell = [o cell];
if([cell respondsToSelector: @selector(formatter)])
{
id formatter = [o formatter];
if([formatter isKindOfClass: [NSFormatter class]])
{
NSString *ident = NSStringFromClass([formatter class]);
[[IBInspectorManager sharedInspectorManager]
addInspectorModeWithIdentifier: ident
forObject: o
localizedLabel: _(@"Formatter")
inspectorClassName: [formatter inspectorClassName]
ordering: -1.0];
}
}
}
}
// view resource dragging delegate...
/**
* Ask if the view accepts the object.
*/
- (BOOL) acceptsViewResourceFromPasteboard: (NSPasteboard *)pb
forObject: (id)obj
atPoint: (NSPoint)p
{
return ([obj respondsToSelector: @selector(setFormatter:)] &&
[[pb types] containsObject: IBFormatterPboardType]);
}
/**
* Perform the action of depositing the object.
*/
- (void) depositViewResourceFromPasteboard: (NSPasteboard *)pb
onObject: (id)obj
atPoint: (NSPoint)p
{
NSData *data = [pb dataForType: IBFormatterPboardType];
id array = [NSUnarchiver unarchiveObjectWithData: data];
if(array != nil)
{
if([array count] > 0)
{
id formatter = [array objectAtIndex: 0];
// Add the formatter if the object accepts one...
if([obj respondsToSelector: @selector(setFormatter:)])
{
// Touch the document...
[[(id<IB>)NSApp activeDocument] touch];
[obj setFormatter: formatter];
RETAIN(formatter);
if ([formatter isMemberOfClass: [NSNumberFormatter class]])
{
id fieldValue = [NSNumber numberWithFloat: 1.123456789];
[obj setStringValue: [fieldValue stringValue]];
[obj setObjectValue: fieldValue];
}
else if ([formatter isMemberOfClass: [NSDateFormatter class]])
{
id fieldValue = [NSDate date];
[obj setStringValue: [fieldValue description]];
[obj setObjectValue: fieldValue];
}
}
}
}
}
/**
* Should we draw the connection frame when the resource is
* dragged in?
*/
- (BOOL) shouldDrawConnectionFrame
{
return NO;
}
/**
* Types of resources accepted by this view.
*/
- (NSArray *)viewResourcePasteboardTypes
{
return [NSArray arrayWithObject: IBFormatterPboardType];
}
@end

Binary file not shown.

View file

@ -0,0 +1,52 @@
# GNUmakefile
#
# Copyright (C) 1999, 2021 Free Software Foundation, Inc.
#
# Author: Gregory Casamento <greg.casamento@gmail.com>
# Date: Nov 2001
#
# 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., 675 Mass Ave, Cambridge, MA 02139, USA.
PACKAGE_NAME = gorm
include $(GNUSTEP_MAKEFILES)/common.make
PALETTE_NAME = 5Formatters
5Formatters_PALETTE_ICON = FormattersPalette
5Formatters_PRINCIPAL_CLASS = FormattersPalette
5Formatters_OBJC_FILES = \
FormattersPalette.m
5Formatters_RESOURCE_FILES = FormattersPalette.tiff \
bytecount_formatter.tiff \
date_comp_formatter.tiff \
energy_formatter.tiff \
measurement_formatter.tiff \
date_interval_formatter.tiff \
length_formatter.tiff \
palette.table
5Formatters_STANDARD_INSTALL = no
-include GNUmakefile.preamble
-include GNUmakefile.local
include $(GNUSTEP_MAKEFILES)/palette.make
#-include GNUmakefile.postamble

View file

@ -0,0 +1,21 @@
# Additional include directories the compiler should search
ADDITIONAL_INCLUDE_DIRS += -I../..
ifeq ($(GNUSTEP_TARGET_OS),mingw32)
ADDITIONAL_LIB_DIRS += \
-L../../GormLib/$(GNUSTEP_OBJ_DIR) \
-L../../GormObjCHeaderParser/$(GNUSTEP_OBJ_DIR) \
-L../../GormPrefs/$(GNUSTEP_OBJ_DIR) \
-L../../GormCore/$(GNUSTEP_OBJ_DIR)
ADDITIONAL_GUI_LIBS += -lGorm -lGormCore
endif
ifeq ($(GNUSTEP_TARGET_OS),cygwin)
ADDITIONAL_LIB_DIRS += \
-L../../GormLib/$(GNUSTEP_OBJ_DIR) \
-L../../GormObjCHeaderParser/$(GNUSTEP_OBJ_DIR) \
-L../../GormPrefs/$(GNUSTEP_OBJ_DIR) \
-L../../GormCore/$(GNUSTEP_OBJ_DIR)
4Data_LIBRARIES_DEPEND_UPON += -lGorm -lGormCore
endif

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,6 @@
{
NOTE = "Automatically generated, do not edit!";
NibFile = "";
Class = "FormattersPalette";
Icon = "FormattersPalette";
}

View file

@ -0,0 +1,48 @@
# GNUmakefile
#
# Copyright (C) 1999 Free Software Foundation, Inc.
#
# Author: Laurent Julliard <laurent@julliard-online.org>
# Date: Nov 2001
#
# 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., 675 Mass Ave, Cambridge, MA 02139, USA.
PACKAGE_NAME = gorm
include $(GNUSTEP_MAKEFILES)/common.make
PALETTE_NAME = 6GridStack
6GridStack_PALETTE_ICON = GridStackPalette
6GridStack_PRINCIPAL_CLASS = GridStackPalette
6GridStack_OBJC_FILES = \
GridStackPalette.m
6GridStack_RESOURCE_FILES = GridStackPalette.tiff \
stack_view.tiff \
grid_view.tiff \
palette.table
6GridStack_STANDARD_INSTALL = no
-include GNUmakefile.preamble
-include GNUmakefile.local
include $(GNUSTEP_MAKEFILES)/palette.make
#-include GNUmakefile.postamble

View file

@ -0,0 +1,21 @@
# Additional include directories the compiler should search
ADDITIONAL_INCLUDE_DIRS += -I../..
ifeq ($(GNUSTEP_TARGET_OS),mingw32)
ADDITIONAL_LIB_DIRS += \
-L../../GormLib/$(GNUSTEP_OBJ_DIR) \
-L../../GormObjCHeaderParser/$(GNUSTEP_OBJ_DIR) \
-L../../GormPrefs/$(GNUSTEP_OBJ_DIR) \
-L../../GormCore/$(GNUSTEP_OBJ_DIR)
ADDITIONAL_GUI_LIBS += -lGorm -lGormCore
endif
ifeq ($(GNUSTEP_TARGET_OS),cygwin)
ADDITIONAL_LIB_DIRS += \
-L../../GormLib/$(GNUSTEP_OBJ_DIR) \
-L../../GormObjCHeaderParser/$(GNUSTEP_OBJ_DIR) \
-L../../GormPrefs/$(GNUSTEP_OBJ_DIR) \
-L../../GormCore/$(GNUSTEP_OBJ_DIR)
4Data_LIBRARIES_DEPEND_UPON += -lGorm -lGormCore
endif

View file

@ -0,0 +1,35 @@
/* GridStackPalette
Copyright (C) 2021 Free Software Foundation, Inc.
Author: Gregory Casamento <greg.casamento@gmail.com>
Date: June 1 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_GridStackPalette_h
#define INCLUDED_GridStackPalette_h
#include <Foundation/Foundation.h>
#include <InterfaceBuilder/InterfaceBuilder.h>
@interface GridStackPalette: IBPalette <IBViewResourceDraggingDelegates>
@end
#endif

View file

@ -0,0 +1,207 @@
/* GridStackPalette.m
Copyright (C) 2021 Free Software Foundation, Inc.
Author: Gregory Casamento <greg.casamento@gmail.com>
Date: Jun 4 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.
*/
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
#import <InterfaceBuilder/InterfaceBuilder.h>
#import "GridStackPalette.h"
/* ----------------------------------------------------------------------
* Some additions to the NSGridView, NSStackView Classes specific to Gorm
* ----------------------------------------------------------------------*/
@implementation GridStackPalette
- (id) init
{
if((self = [super init]) != nil)
{
// Make ourselves a delegate, so that when the formatter is dragged in,
// this code is called...
[NSView registerViewResourceDraggingDelegate: self];
// subscribe to the notification...
[[NSNotificationCenter defaultCenter]
addObserver: self
selector: @selector(willInspectObject:)
name: IBWillInspectObjectNotification
object: nil];
}
return self;
}
- (void) dealloc
{
[NSView unregisterViewResourceDraggingDelegate: self];
[[NSNotificationCenter defaultCenter] removeObserver: self];
[super dealloc];
}
- (void) placeView: (NSView *)o
withImageNamed: (NSString *)imageName
atRect: (NSRect)frame
inView: (NSView *)contents
toolTip: (NSString *)tooltip
{
id v;
NSImage *img;
NSString *path = [[NSBundle bundleForClass: [self class]]
pathForImageResource: imageName];
img = [[NSImage alloc] initWithContentsOfFile: path];
v = [[NSImageView alloc] initWithFrame: frame];
[v setImageFrameStyle: NSImageFramePhoto];
[v setImageScaling: NSScaleProportionally];
[v setImageAlignment: NSImageAlignCenter];
[v setImage: img];
[v setToolTip: tooltip];
[contents addSubview: v];
[self associateObject: o type: IBViewPboardType with: v];
RELEASE(v);
RELEASE(img);
}
- (void) finishInstantiate
{
NSView *contents;
originalWindow = [[NSWindow alloc] initWithContentRect:
NSMakeRect(0, 0, 272, 192)
styleMask: NSBorderlessWindowMask
backing: NSBackingStoreRetained
defer: NO];
[originalWindow setTitle: @"NSGridView / NSStackView"];
contents = [originalWindow contentView];
/* views */
[self placeView: [[NSStackView alloc] initWithFrame: NSMakeRect(10, 10, 100, 100)]
withImageNamed: @"stack_view"
atRect: NSMakeRect(192, 48, 43, 43)
inView: contents
toolTip: @"NSStackView"];
[self placeView: [[NSGridView alloc] initWithFrame: NSMakeRect(10, 10, 100, 100)]
withImageNamed: @"grid_view"
atRect: NSMakeRect(144, 48, 43, 43)
inView: contents
toolTip: @"NSGridView"];
}
- (void) willInspectObject: (NSNotification *)notification
{
id o = [notification object];
if([o respondsToSelector: @selector(cell)])
{
id cell = [o cell];
if([cell respondsToSelector: @selector(formatter)])
{
id formatter = [o formatter];
if([formatter isKindOfClass: [NSFormatter class]])
{
NSString *ident = NSStringFromClass([formatter class]);
[[IBInspectorManager sharedInspectorManager]
addInspectorModeWithIdentifier: ident
forObject: o
localizedLabel: _(@"Formatter")
inspectorClassName: [formatter inspectorClassName]
ordering: -1.0];
}
}
}
}
// view resource dragging delegate...
/**
* Ask if the view accepts the object.
*/
- (BOOL) acceptsViewResourceFromPasteboard: (NSPasteboard *)pb
forObject: (id)obj
atPoint: (NSPoint)p
{
return ([obj respondsToSelector: @selector(setFormatter:)] &&
[[pb types] containsObject: IBFormatterPboardType]);
}
/**
* Perform the action of depositing the object.
*/
- (void) depositViewResourceFromPasteboard: (NSPasteboard *)pb
onObject: (id)obj
atPoint: (NSPoint)p
{
NSData *data = [pb dataForType: IBFormatterPboardType];
id array = [NSUnarchiver unarchiveObjectWithData: data];
if(array != nil)
{
if([array count] > 0)
{
id formatter = [array objectAtIndex: 0];
// Add the formatter if the object accepts one...
if([obj respondsToSelector: @selector(setFormatter:)])
{
// Touch the document...
[[(id<IB>)NSApp activeDocument] touch];
[obj setFormatter: formatter];
RETAIN(formatter);
if ([formatter isMemberOfClass: [NSNumberFormatter class]])
{
id fieldValue = [NSNumber numberWithFloat: 1.123456789];
[obj setStringValue: [fieldValue stringValue]];
[obj setObjectValue: fieldValue];
}
else if ([formatter isMemberOfClass: [NSDateFormatter class]])
{
id fieldValue = [NSDate date];
[obj setStringValue: [fieldValue description]];
[obj setObjectValue: fieldValue];
}
}
}
}
}
/**
* Should we draw the connection frame when the resource is
* dragged in?
*/
- (BOOL) shouldDrawConnectionFrame
{
return NO;
}
/**
* Types of resources accepted by this view.
*/
- (NSArray *)viewResourcePasteboardTypes
{
return [NSArray arrayWithObject: IBViewPboardType];
}
@end

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,6 @@
{
NOTE = "Automatically generated, do not edit!";
NibFile = "";
Class = "GridStackPalette";
Icon = "GridStackPalette";
}

Binary file not shown.