mirror of
https://github.com/gnustep/apps-gorm.git
synced 2025-02-24 20:11:20 +00:00
* Palettes/3Containers/main.m * Palettes/3Containers/GormNSBrowser.m * Palettes/3Containers/GormNSBrowser.h * Gorm.m * GormDocument.m Subclass of NSBrowser and NSTableView to be able to set the delegate for runtime only (there is a dummy delegate for edit-time and test-time). Those classes are encoded as NSBrowser/NSTableView and NSTableView/NSBrowser are decoded as GormNSBrowser/GormNSTableView * Palettes/1Windows/GNUmakefile * Palettes/1Windows/GormNSWindow.h * Palettes/1Windows/GormNSWindow.m * Palettes/1Windows/main.m * GormDocument.m * Gorm.m Subclass of NSWindow to be able to choose the stylemask and to still be able to resize/close/minimize the window in the editor regardless of the stylemask. This class is encoded as NSWindow and NSWindow is decoded as GormNSWindow. * GormDocument.m ([-attachObect:toParent]): NSTableView & NSTextView objects contained in NSScrollView are now added. Connections to and from those objects are now available. * GormWindowEditor.m: new bestKnownSuperview function (original patch from Stefan Urbanek <stefanurbanek@yahoo.fr> modified to let the user select the NSScrollView or the NSTextView/ NSTableView contained within the NSScrollView). * Palettes/3Containers/inspectors.m * Palettes/3Containers/GormBrowserInspector.gorm * Palettes/3Containers/GormTableViewInspector.gorm NSTableView and NSBrowser inspectors updated (new tag field) (patch from Stefan Urbanek <stefanurbanek@yahoo.fr>) git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@12559 72102866-910b-0410-8b05-ffd578937521
347 lines
8.7 KiB
Objective-C
347 lines
8.7 KiB
Objective-C
/* inspectors - Various inspectors for control elements
|
|
|
|
Copyright (C) 2001 Free Software Foundation, Inc.
|
|
|
|
Author: Laurent Julliard <laurent@julliard-online.org>
|
|
Date: Aug 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.
|
|
*/
|
|
|
|
#include <Foundation/Foundation.h>
|
|
#include <AppKit/AppKit.h>
|
|
#include "../../GormPrivate.h"
|
|
|
|
/* This macro makes sure that the string contains a value, even if @"" */
|
|
#define VSTR(str) ({id _str = str; (_str) ? _str : @"";})
|
|
|
|
/*----------------------------------------------------------------------------
|
|
* NSBrowser
|
|
*/
|
|
@implementation NSBrowser (IBInspectorClassNames)
|
|
|
|
- (NSString*) inspectorClassName
|
|
{
|
|
return @"GormBrowserAttributesInspector";
|
|
}
|
|
|
|
@end
|
|
|
|
@interface GormBrowserAttributesInspector : IBInspector
|
|
{
|
|
id optionMatrix;
|
|
id tagField;
|
|
}
|
|
|
|
- (void) _getValuesFromObject: (id)anObject;
|
|
@end
|
|
|
|
@implementation GormBrowserAttributesInspector
|
|
|
|
|
|
- (void) _setValuesFromControl: (id)control
|
|
{
|
|
if (control == optionMatrix)
|
|
{
|
|
BOOL flag;
|
|
|
|
flag = ([[control cellAtRow: 0 column: 0] state] == NSOnState) ? YES : NO;
|
|
[object setAllowsMultipleSelection: flag];
|
|
flag = ([[control cellAtRow: 1 column: 0] state] == NSOnState) ? YES : NO;
|
|
[object setAllowsEmptySelection: flag];
|
|
flag = ([[control cellAtRow: 2 column: 0] state] == NSOnState) ? YES : NO;
|
|
[object setAllowsBranchSelection: flag];
|
|
|
|
flag = ([[control cellAtRow: 3 column: 0] state] == NSOnState) ? YES : NO;
|
|
[object setSeparatesColumns: flag];
|
|
|
|
flag = ([[control cellAtRow: 4 column: 0] state] == NSOnState) ? YES : NO;
|
|
[object setTitled: flag];
|
|
|
|
flag = ([[control cellAtRow: 5 column: 0] state] == NSOnState) ? YES : NO;
|
|
[object setHasHorizontalScroller: flag];
|
|
}
|
|
else if( control == tagField )
|
|
{
|
|
[object setTag:[[tagField cellAtIndex:0] intValue]];
|
|
}
|
|
}
|
|
|
|
- (void) _getValuesFromObject: anObject
|
|
{
|
|
|
|
if (anObject != object)
|
|
{
|
|
return;
|
|
}
|
|
|
|
[optionMatrix deselectAllCells];
|
|
if ([anObject allowsMultipleSelection])
|
|
[optionMatrix selectCellAtRow: 0 column: 0];
|
|
if ([anObject allowsEmptySelection])
|
|
[optionMatrix selectCellAtRow: 1 column: 0];
|
|
if ([anObject allowsBranchSelection])
|
|
[optionMatrix selectCellAtRow: 2 column: 0];
|
|
if ([anObject separatesColumns])
|
|
[optionMatrix selectCellAtRow: 3 column: 0];
|
|
if ([anObject isTitled])
|
|
[optionMatrix selectCellAtRow: 4 column: 0];
|
|
if ([anObject hasHorizontalScroller])
|
|
[optionMatrix selectCellAtRow: 5 column: 0];
|
|
|
|
[[tagField cellAtIndex:0] setIntValue:[anObject tag]];
|
|
}
|
|
|
|
- (void) dealloc
|
|
{
|
|
RELEASE(window);
|
|
RELEASE(okButton);
|
|
[super dealloc];
|
|
}
|
|
|
|
- (id) init
|
|
{
|
|
if ([super init] == nil)
|
|
{
|
|
return nil;
|
|
}
|
|
|
|
if ([NSBundle loadNibNamed: @"GormBrowserInspector" owner: self] == NO)
|
|
{
|
|
NSLog(@"Could not gorm GormBrowserInspector");
|
|
return nil;
|
|
}
|
|
|
|
return self;
|
|
}
|
|
|
|
- (void) ok: (id)sender
|
|
{
|
|
[self _setValuesFromControl: sender];
|
|
}
|
|
|
|
- (void) setObject: (id)anObject
|
|
{
|
|
[super setObject: anObject];
|
|
[self _getValuesFromObject: anObject];
|
|
}
|
|
|
|
@end
|
|
|
|
/*----------------------------------------------------------------------------
|
|
* NSTableView (possibly embedded in a Scroll view)
|
|
*/
|
|
@implementation NSTableView (IBInspectorClassNames)
|
|
|
|
- (NSString*) inspectorClassName
|
|
{
|
|
return @"GormTableViewAttributesInspector";
|
|
}
|
|
|
|
@end
|
|
|
|
@interface GormTableViewAttributesInspector : IBInspector
|
|
{
|
|
id selectionMatrix;
|
|
id verticalScrollerSwitch;
|
|
id horizontalScrollerSwitch;
|
|
id borderMatrix;
|
|
id rowsHeightForm;
|
|
id optionMatrix;
|
|
id tagField;
|
|
}
|
|
|
|
- (void) _getValuesFromObject: (id)anObject;
|
|
@end
|
|
|
|
@implementation GormTableViewAttributesInspector
|
|
|
|
|
|
- (void) _setValuesFromControl: (id)control
|
|
{
|
|
BOOL flag;
|
|
BOOL isScrollView;
|
|
id scrollView;
|
|
|
|
scrollView = [[object superview] superview];
|
|
isScrollView = [ scrollView isKindOfClass: [NSScrollView class]];
|
|
|
|
if (control == optionMatrix)
|
|
{
|
|
flag = ([[control cellAtRow: 0 column: 0] state] == NSOnState) ? YES : NO;
|
|
[object setAllowsMultipleSelection: flag];
|
|
flag = ([[control cellAtRow: 1 column: 0] state] == NSOnState) ? YES : NO;
|
|
[object setAllowsEmptySelection: flag];
|
|
flag = ([[control cellAtRow: 2 column: 0] state] == NSOnState) ? YES : NO;
|
|
[object setAllowsColumnSelection: flag];
|
|
}
|
|
|
|
else if ( (control == verticalScrollerSwitch) && isScrollView)
|
|
{
|
|
flag = ([control state] == NSOnState) ? YES : NO;
|
|
[scrollView setHasVerticalScroller: flag];
|
|
}
|
|
|
|
else if ( (control == horizontalScrollerSwitch) && isScrollView)
|
|
{
|
|
flag = ([control state] == NSOnState) ? YES : NO;
|
|
[scrollView setHasHorizontalScroller: flag];
|
|
}
|
|
|
|
else if ( (control == borderMatrix) && isScrollView)
|
|
{
|
|
[scrollView setBorderType: [[control selectedCell] tag]];
|
|
}
|
|
|
|
else if (control == rowsHeightForm)
|
|
{
|
|
[object setRowHeight: [[control cellAtIndex: 0] intValue] ];
|
|
}
|
|
|
|
else if (control == optionMatrix)
|
|
{
|
|
flag = ([[control cellAtRow: 0 column: 0] state] == NSOnState) ? YES : NO;
|
|
[object setDrawsGrid: flag];
|
|
flag = ([[control cellAtRow: 1 column: 0] state] == NSOnState) ? YES : NO;
|
|
[object setAllowsColumnResizing: flag];
|
|
flag = ([[control cellAtRow: 2 column: 0] state] == NSOnState) ? YES : NO;
|
|
[object setAllowsColumnReordering: flag];
|
|
}
|
|
else if( control == tagField )
|
|
{
|
|
[object setTag:[[tagField cellAtIndex:0] intValue]];
|
|
}
|
|
}
|
|
|
|
- (void) _getValuesFromObject: anObject
|
|
{
|
|
BOOL isScrollView;
|
|
id scrollView;
|
|
|
|
scrollView = [[object superview] superview];
|
|
isScrollView = [ scrollView isKindOfClass: [NSScrollView class]];
|
|
|
|
if (anObject != object)
|
|
{
|
|
return;
|
|
}
|
|
|
|
[selectionMatrix deselectAllCells];
|
|
if ([anObject allowsMultipleSelection])
|
|
[optionMatrix selectCellAtRow: 0 column: 0];
|
|
if ([anObject allowsEmptySelection])
|
|
[optionMatrix selectCellAtRow: 1 column: 0];
|
|
if ([anObject allowsColumnSelection])
|
|
[optionMatrix selectCellAtRow: 2 column: 0];
|
|
|
|
if (isScrollView)
|
|
{
|
|
[verticalScrollerSwitch setEnabled: YES];
|
|
[verticalScrollerSwitch setState:
|
|
([scrollView hasVerticalScroller]) ? NSOnState : NSOffState];
|
|
|
|
[horizontalScrollerSwitch setEnabled: YES];
|
|
[horizontalScrollerSwitch setState:
|
|
([scrollView hasVerticalScroller]) ? NSOnState : NSOffState];
|
|
|
|
[borderMatrix setEnabled: YES];
|
|
[borderMatrix selectCellWithTag: [scrollView borderType]];
|
|
}
|
|
else
|
|
{
|
|
[verticalScrollerSwitch setEnabled: NO];
|
|
[horizontalScrollerSwitch setEnabled: NO];
|
|
[borderMatrix setEnabled: NO];
|
|
}
|
|
|
|
[[rowsHeightForm cellAtIndex: 0] setIntValue: [anObject rowHeight] ];
|
|
|
|
[optionMatrix deselectAllCells];
|
|
if ([anObject drawsGrid])
|
|
[optionMatrix selectCellAtRow: 0 column: 0];
|
|
if ([anObject allowsColumnResizing])
|
|
[optionMatrix selectCellAtRow: 1 column: 0];
|
|
if ([anObject allowsColumnReordering])
|
|
[optionMatrix selectCellAtRow: 2 column: 0];
|
|
[[tagField cellAtIndex:0] setIntValue:[anObject tag]];
|
|
}
|
|
|
|
- (void) dealloc
|
|
{
|
|
RELEASE(window);
|
|
RELEASE(okButton);
|
|
[super dealloc];
|
|
}
|
|
|
|
- (id) init
|
|
{
|
|
if ([super init] == nil)
|
|
{
|
|
return nil;
|
|
}
|
|
|
|
if ([NSBundle loadNibNamed: @"GormTableViewInspector" owner: self] == NO)
|
|
{
|
|
NSLog(@"Could not gorm GormTableViewInspector");
|
|
return nil;
|
|
}
|
|
|
|
return self;
|
|
}
|
|
|
|
- (void) ok: (id)sender
|
|
{
|
|
[self _setValuesFromControl: sender];
|
|
}
|
|
|
|
- (void) setObject: (id)anObject
|
|
{
|
|
[super setObject: anObject];
|
|
[self _getValuesFromObject: anObject];
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
/*----------------------------------------------------------------------------
|
|
* NSScrollView
|
|
*/
|
|
|
|
/*
|
|
* For now NSScrollView has no inspector in itself. It is only used as a
|
|
* convenience in the NSTableView and NSTextView controls and there
|
|
* are minimal NSScrollView settings in the inspector of these 2 controls
|
|
* (like horizontal and vertical scrollbar)
|
|
*/
|
|
|
|
@implementation NSScrollView (IBInspectorClassNames)
|
|
|
|
- (NSString*) inspectorClassName
|
|
{
|
|
return @"GormEmptyInspector";
|
|
}
|
|
|
|
@end
|
|
|
|
@interface GormScrollViewAttributesInspector : IBInspector
|
|
{
|
|
}
|
|
@end
|
|
|
|
@implementation GormScrollViewAttributesInspector
|
|
@end
|
|
|