mirror of
https://github.com/gnustep/apps-gorm.git
synced 2025-04-23 06:20:47 +00:00
GormBoxEditor.h
GormBoxEditor.m GormButtonEditor.h GormButtonEditor.m GormControlEditor.h GormControlEditor.m GormInternalViewEditor.h GormInternalViewEditor.m GormMatrixEditor.h GormPlacementInfo.h GormPosingView.h GormPosingView.m GormSplitViewEditor.h GormSplitViewEditor.m GormTabViewEditor.h GormTabViewEditor.m GormViewEditor.h GormViewEditor.m GormViewWithContentViewEditor.h GormViewWithContentViewEditor.m GormViewWithSubviewsEditor.h GormViewWithSubviewsEditor.m Palettes/3Containers/GormTableViewEditor.h Palettes/3Containers/GormTableViewEditor.m ChangeLog GNUmakefile Gorm.h Gorm.m GormClassEditor.m GormClassManager.m GormCustomClassInspector.m GormCustomView.m GormDocument.m GormMatrixEditor.m GormObjectEditor.m GormOutlineView.m GormPrivate.h GormWindowEditor.m Palettes/0Menus/GormMenuEditor.m Palettes/1Windows/main.m Palettes/2Controls/GormBoxInspector.gorm Palettes/2Controls/GormButtonInspector.gorm Palettes/2Controls/GormTextFieldInspector.gorm Palettes/2Controls/main.m Palettes/3Containers/GNUmakefile Palettes/3Containers/GormNSBrowser.m Palettes/3Containers/GormNSOutlineView.m Palettes/3Containers/GormNSTableView.h Palettes/3Containers/GormTableColumnInspector.classes Palettes/3Containers/GormTableColumnInspector.gorm Palettes/3Containers/GormTableViewInspector.gorm Palettes/3Containers/inspectors.m Palettes/3Containers/main.m Palettes/4Data/inspectors.m Palettes/4Data/main.m git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@14267 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
264b05f679
commit
420c315961
55 changed files with 9249 additions and 1664 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
2002-08-14 Pierre-Yves Rivaille
|
||||
|
||||
* Major changes in editing widgets.
|
||||
* Basic support for NSSplitView and NSTabView.
|
||||
* Intelligent placement and resizing of widget.
|
||||
* Dropping widget into not yet opened box/tabview.
|
||||
* grouping into splitviews/boxes and ungrouping.
|
||||
* direct editing of NSButton's and NSBox's title.
|
||||
* Many small fixes.
|
||||
|
||||
2002-07-22 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* Resources/GormCustomClassInspector.[gorm,classes]: Added.
|
||||
|
|
28
GNUmakefile
28
GNUmakefile
|
@ -115,7 +115,23 @@ Gorm_HEADERS = \
|
|||
GormPrivate.h \
|
||||
GormCustomView.h \
|
||||
GormOutlineView.h \
|
||||
GormCustomClassInspector.h
|
||||
GormCustomClassInspector.h \
|
||||
GormMatrixEditor.h \
|
||||
GormPalettesManager.h \
|
||||
GormViewEditor.h \
|
||||
GormViewWithSubviewsEditor.h \
|
||||
GormViewWithContentViewEditor.h \
|
||||
GormBoxEditor.h \
|
||||
GormClassManager.h \
|
||||
GormControlEditor.h \
|
||||
GormDocument.h \
|
||||
GormFilesOwner.h \
|
||||
GormInspectorsManager.h \
|
||||
GormInternalViewEditor.h \
|
||||
GormButtonEditor.h \
|
||||
GormTabViewEditor.h \
|
||||
GormSplitViewEditor.h \
|
||||
GormPlacementInfo.h
|
||||
|
||||
Gorm_OBJC_FILES = \
|
||||
Gorm.m \
|
||||
|
@ -127,12 +143,20 @@ Gorm_OBJC_FILES = \
|
|||
GormFilesOwner.m \
|
||||
GormClassEditor.m \
|
||||
GormMatrixEditor.m \
|
||||
GormTableViewEditor.m \
|
||||
GormObjectEditor.m \
|
||||
GormObjectInspector.m \
|
||||
GormWindowEditor.m \
|
||||
GormClassManager.m \
|
||||
GormInspectorsManager.m \
|
||||
GormViewEditor.m \
|
||||
GormViewWithSubviewsEditor.m \
|
||||
GormViewWithContentViewEditor.m \
|
||||
GormBoxEditor.m \
|
||||
GormControlEditor.m \
|
||||
GormButtonEditor.m \
|
||||
GormSplitViewEditor.m \
|
||||
GormTabViewEditor.m \
|
||||
GormInternalViewEditor.m \
|
||||
GormPalettesManager.m \
|
||||
GormOutlineView.m \
|
||||
GormCustomClassInspector.m
|
||||
|
|
63
Gorm.h
63
Gorm.h
|
@ -140,9 +140,26 @@ extern NSString *IBClassNameChangedNotification;
|
|||
* must implement.
|
||||
*/
|
||||
@protocol IBSelectionOwners <NSObject>
|
||||
- (unsigned) selectionCount;
|
||||
// - (unsigned) selectionCount;
|
||||
- (NSArray*) selection;
|
||||
- (void) drawSelection;
|
||||
// - (void) drawSelection;
|
||||
|
||||
/*
|
||||
* This method is used to draw or remove markup that identifies selected
|
||||
* objects within the object being edited.
|
||||
*/
|
||||
- (void) makeSelectionVisible: (BOOL)flag;
|
||||
|
||||
/*
|
||||
* This method changes the current selection to those objects in the array.
|
||||
*/
|
||||
- (void) selectObjects: (NSArray*)objects;
|
||||
|
||||
// /*
|
||||
// * This method places the current selection from the editor on the pasteboard.
|
||||
// */
|
||||
// - (void) copySelection;
|
||||
|
||||
@end
|
||||
|
||||
/*
|
||||
|
@ -150,7 +167,7 @@ extern NSString *IBClassNameChangedNotification;
|
|||
* area in which Gorm differs most from InterfaceBuilder, as I have no clear
|
||||
* idea of how InterfaceBuilder editors are meant to operate.
|
||||
*/
|
||||
@protocol IBEditors <IBSelectionOwners>
|
||||
@protocol IBEditors
|
||||
/*
|
||||
* Decide whether an editor can accept data from the pasteboard.
|
||||
*/
|
||||
|
@ -173,15 +190,6 @@ extern NSString *IBClassNameChangedNotification;
|
|||
*/
|
||||
- (void) close;
|
||||
|
||||
/*
|
||||
* Close subeditors of this editor.
|
||||
*/
|
||||
- (void) closeSubeditors;
|
||||
|
||||
/*
|
||||
* This method places the current selection from the editor on the pasteboard.
|
||||
*/
|
||||
- (void) copySelection;
|
||||
|
||||
/*
|
||||
* Deactivate an editor - removes it from the view hierarchy so that objects
|
||||
|
@ -191,10 +199,10 @@ extern NSString *IBClassNameChangedNotification;
|
|||
*/
|
||||
- (void) deactivate;
|
||||
|
||||
/*
|
||||
* This method deletes all the objects in the current selection in the editor.
|
||||
*/
|
||||
- (void) deleteSelection;
|
||||
// /*
|
||||
// * This method deletes all the objects in the current selection in the editor.
|
||||
// */
|
||||
// - (void) deleteSelection;
|
||||
|
||||
/*
|
||||
* This method returns the document that owns the object that the editor edits.
|
||||
|
@ -206,17 +214,6 @@ extern NSString *IBClassNameChangedNotification;
|
|||
*/
|
||||
- (id) editedObject;
|
||||
|
||||
/*
|
||||
* This method is used to draw or remove markup that identifies selected
|
||||
* objects within the object being edited.
|
||||
*/
|
||||
- (void) makeSelectionVisible: (BOOL)flag;
|
||||
|
||||
/*
|
||||
* This method is used to open an editor for an object within the object
|
||||
* currently being edited.
|
||||
*/
|
||||
- (id<IBEditors>) openSubeditorForObject: (id)anObject;
|
||||
|
||||
/*
|
||||
* This method is used to ensure that the editor is visible on screen.
|
||||
|
@ -227,22 +224,14 @@ extern NSString *IBClassNameChangedNotification;
|
|||
* This method is used to add the contents of the pasteboard to the current
|
||||
* selection of objects within the editor.
|
||||
*/
|
||||
- (void) pasteInSelection;
|
||||
// - (void) pasteInSelection;
|
||||
|
||||
/*
|
||||
* FIXME - I don't think we use this.
|
||||
*/
|
||||
- (void) resetObject: (id)anObject;
|
||||
|
||||
/*
|
||||
* This method changes the current selection to those objects in the array.
|
||||
*/
|
||||
- (void) selectObjects: (NSArray*)objects;
|
||||
|
||||
/*
|
||||
* FIXME - I don't think we use this.
|
||||
*/
|
||||
- (void) validateEditing;
|
||||
|
||||
/*
|
||||
* When an editor resigns the selection ownership, all editors are asked if
|
||||
|
@ -289,7 +278,7 @@ extern NSString *IBClassNameChangedNotification;
|
|||
- (id) objectForName: (NSString*)aName;
|
||||
- (NSArray*) objects;
|
||||
- (id<IBEditors>) openEditorForObject: (id)anObject;
|
||||
- (id<IBEditors>) parentEditorForEditor: (id<IBEditors>)anEditor;
|
||||
- (id<IBEditors, IBSelectionOwners>) parentEditorForEditor: (id<IBEditors>)anEditor;
|
||||
- (id) parentOfObject: (id)anObject;
|
||||
- (NSArray*) pasteType: (NSString*)aType
|
||||
fromPasteboard: (NSPasteboard*)aPasteboard
|
||||
|
|
48
Gorm.m
48
Gorm.m
|
@ -39,6 +39,9 @@ NSString *GormLinkPboardType = @"GormLinkPboardType";
|
|||
|
||||
@class InfoPanel;
|
||||
|
||||
// we had this include for grouping/ungrouping selectors
|
||||
#import "GormViewWithContentViewEditor.h"
|
||||
|
||||
@implementation NSCell (GormAdditions)
|
||||
/*
|
||||
* this methods is directly coming from NSCell.m
|
||||
|
@ -294,6 +297,32 @@ NSString *GormLinkPboardType = @"GormLinkPboardType";
|
|||
return self;
|
||||
}
|
||||
|
||||
- (id) groupSelectionInSplitView: (id)sender
|
||||
{
|
||||
if ([[selectionOwner selection] count] < 2
|
||||
|| [selectionOwner respondsToSelector: @selector(groupSelectionInSplitView)] == NO)
|
||||
return nil;
|
||||
[(id)selectionOwner groupSelectionInSplitView];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id) groupSelectionInBox: (id)sender
|
||||
{
|
||||
if ([selectionOwner respondsToSelector: @selector(groupSelectionInBox)] == NO)
|
||||
return nil;
|
||||
[(id)selectionOwner groupSelectionInBox];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id) ungroup: (id)sender
|
||||
{
|
||||
NSLog(@"ungroup: selectionOwner %@", selectionOwner);
|
||||
if ([selectionOwner respondsToSelector: @selector(ungroup)] == NO)
|
||||
return nil;
|
||||
[(id)selectionOwner ungroup];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
|
@ -578,6 +607,9 @@ NSString *GormLinkPboardType = @"GormLinkPboardType";
|
|||
[aMenu addItemWithTitle: @"Close"
|
||||
action: @selector(close:)
|
||||
keyEquivalent: @""];
|
||||
[aMenu addItemWithTitle: @"Debug"
|
||||
action: @selector(debug:)
|
||||
keyEquivalent: @""];
|
||||
menuItem = [mainMenu addItemWithTitle: @"Document"
|
||||
action: NULL
|
||||
keyEquivalent: @""];
|
||||
|
@ -610,6 +642,15 @@ NSString *GormLinkPboardType = @"GormLinkPboardType";
|
|||
[aMenu addItemWithTitle: @"Set Name..."
|
||||
action: @selector(setName:)
|
||||
keyEquivalent: @""];
|
||||
[aMenu addItemWithTitle: @"Group in splitview"
|
||||
action: @selector(groupSelectionInSplitView:)
|
||||
keyEquivalent: @""];
|
||||
[aMenu addItemWithTitle: @"Group in box"
|
||||
action: @selector(groupSelectionInBox:)
|
||||
keyEquivalent: @""];
|
||||
[aMenu addItemWithTitle: @"Ungroup"
|
||||
action: @selector(ungroup:)
|
||||
keyEquivalent: @""];
|
||||
[[aMenu addItemWithTitle: @"Font Panel"
|
||||
action: @selector(orderFrontFontPanel:)
|
||||
keyEquivalent: @"f"] setTarget: [NSFontManager sharedFontManager]];
|
||||
|
@ -845,6 +886,11 @@ NSLog(@"StartupTime %f", [startDate timeIntervalSinceNow]);
|
|||
return [[self palettesManager] openPalette: sender];
|
||||
}
|
||||
|
||||
- (void) debug: (id) sender
|
||||
{
|
||||
[[self activeDocument] performSelector: @selector(printAllEditors)];
|
||||
}
|
||||
|
||||
- (id) miniaturize: (id)sender
|
||||
{
|
||||
NSWindow *window = [(id)[self activeDocument] window];
|
||||
|
@ -1252,6 +1298,8 @@ main(int argc, const char **argv)
|
|||
|
||||
NSImageDoesCaching = YES;
|
||||
//[NSObject enableDoubleReleaseCheck: YES];
|
||||
|
||||
// [GormPosingView poseAsClass: [NSView class]];
|
||||
|
||||
startDate = [[NSDate alloc] init];
|
||||
NSApplicationMain(argc, argv);
|
||||
|
|
33
GormBoxEditor.h
Normal file
33
GormBoxEditor.h
Normal file
|
@ -0,0 +1,33 @@
|
|||
/* GormBoxEditor.h
|
||||
*
|
||||
* Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
*
|
||||
* Author: Pierre-Yves Rivaille <pyrivail@ens-lyon.fr>
|
||||
* Date: 2002
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#import "GormViewWithContentViewEditor.h"
|
||||
#import "GormInternalViewEditor.h"
|
||||
|
||||
@interface GormBoxEditor : GormViewWithSubviewsEditor
|
||||
{
|
||||
GormInternalViewEditor *contentViewEditor;
|
||||
}
|
||||
- (NSArray *)destroyAndListSubviews;
|
||||
@end
|
686
GormBoxEditor.m
Normal file
686
GormBoxEditor.m
Normal file
|
@ -0,0 +1,686 @@
|
|||
/* GormBoxEditor.m
|
||||
*
|
||||
* Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
*
|
||||
* Author: Pierre-Yves Rivaille <pyrivail@ens-lyon.fr>
|
||||
* Date: 2002
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
#import <AppKit/AppKit.h>
|
||||
|
||||
#import "GormPrivate.h"
|
||||
|
||||
#import "GormBoxEditor.h"
|
||||
|
||||
#import "GormInternalViewEditor.h"
|
||||
|
||||
#define _EO ((NSBox *)_editedObject)
|
||||
|
||||
@class GormWindowEditor;
|
||||
|
||||
@implementation NSBox (GormObjectAdditions)
|
||||
- (NSString*) editorClassName
|
||||
{
|
||||
return @"GormBoxEditor";
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
|
||||
@implementation GormBoxEditor
|
||||
|
||||
- (void) setOpened: (BOOL) flag
|
||||
{
|
||||
[super setOpened: flag];
|
||||
if (flag == YES)
|
||||
{
|
||||
[document setSelectionFromEditor: contentViewEditor];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
RELEASE(selection);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
||||
- (BOOL) activate
|
||||
{
|
||||
if ([super activate])
|
||||
{
|
||||
NSView *contentView = [_EO contentView];
|
||||
|
||||
contentViewEditor = [document editorForObject: contentView
|
||||
inEditor: self
|
||||
create: YES];
|
||||
return YES;
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
||||
- (void) deactivate
|
||||
{
|
||||
if (activated == YES)
|
||||
{
|
||||
[self deactivateSubeditors];
|
||||
|
||||
[super deactivate];
|
||||
}
|
||||
}
|
||||
|
||||
- (id) initWithObject: (id)anObject
|
||||
inDocument: (id<IBDocuments>)aDocument
|
||||
{
|
||||
opened = NO;
|
||||
openedSubeditor = nil;
|
||||
|
||||
if ((self = [super initWithObject: anObject
|
||||
inDocument: aDocument]) == nil)
|
||||
return nil;
|
||||
|
||||
selection = [[NSMutableArray alloc] initWithCapacity: 5];
|
||||
|
||||
|
||||
|
||||
[self registerForDraggedTypes: [NSArray arrayWithObjects:
|
||||
IBViewPboardType, GormLinkPboardType, IBFormatterPboardType, nil]];
|
||||
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
|
||||
- (void) makeSelectionVisible: (BOOL) value
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
- (void) deleteSelection
|
||||
{
|
||||
int i;
|
||||
int count = [selection count];
|
||||
id temp;
|
||||
|
||||
for (i = count - 1; i >= 0; i--)
|
||||
{
|
||||
temp = [[selection objectAtIndex: i] editedObject];
|
||||
|
||||
[[selection objectAtIndex: i] detachSubviews];
|
||||
[document detachObject: temp];
|
||||
[[selection objectAtIndex: i] close];
|
||||
|
||||
[temp removeFromSuperview];
|
||||
[selection removeObjectAtIndex: i];
|
||||
}
|
||||
|
||||
[self selectObjects: [NSArray array]];
|
||||
|
||||
}
|
||||
|
||||
|
||||
- (void) mouseDown: (NSEvent *) theEvent
|
||||
{
|
||||
BOOL onKnob = NO;
|
||||
|
||||
|
||||
// if we are on one of our own knob, then this event should be processed
|
||||
// by our parent (cause this is a resizing event)
|
||||
{
|
||||
if ([parent respondsToSelector: @selector(selection)] &&
|
||||
[[parent selection] containsObject: _EO])
|
||||
{
|
||||
IBKnobPosition knob = IBNoneKnobPosition;
|
||||
NSPoint mouseDownPoint =
|
||||
[self convertPoint: [theEvent locationInWindow]
|
||||
fromView: nil];
|
||||
knob = GormKnobHitInRect([self bounds],
|
||||
mouseDownPoint);
|
||||
if (knob != IBNoneKnobPosition)
|
||||
onKnob = YES;
|
||||
}
|
||||
if (onKnob == YES)
|
||||
{
|
||||
if (parent)
|
||||
return [parent mouseDown: theEvent];
|
||||
else
|
||||
return [self noResponderFor: @selector(mouseDown:)];
|
||||
}
|
||||
}
|
||||
|
||||
if (opened == NO)
|
||||
{
|
||||
NSLog(@"GormBoxEditor not opened");
|
||||
[super mouseDown: theEvent];
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if ([[_EO hitTest: [theEvent locationInWindow]]
|
||||
isDescendantOf: contentViewEditor])
|
||||
{
|
||||
NSLog(@"md %@ descendant of", self);
|
||||
if ([contentViewEditor isOpened] == NO)
|
||||
[contentViewEditor setOpened: YES];
|
||||
[contentViewEditor mouseDown: theEvent];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"md %@ not descendant of sending to %@", self, _EO);
|
||||
if ([contentViewEditor isOpened] == YES)
|
||||
[contentViewEditor setOpened: NO];
|
||||
|
||||
if ((NSMouseInRect([_EO convertPoint: [theEvent locationInWindow]
|
||||
fromView: nil],
|
||||
[_EO titleRect], NO) == YES)
|
||||
&& ([theEvent clickCount] == 2))
|
||||
{
|
||||
NSTextField *tf =
|
||||
[[NSTextField alloc] initWithFrame:
|
||||
[self convertRect: [_EO titleRect]
|
||||
fromView: _EO]];
|
||||
NSRect frame = [tf frame];
|
||||
frame.origin.x = [self bounds].origin.x + 3;
|
||||
frame.size.width = [self bounds].size.width - 6;
|
||||
frame.origin.y -= 3;
|
||||
frame.size.height += 4;
|
||||
[tf setBordered: YES];
|
||||
[tf setEditable: YES];
|
||||
[tf setBezeled: NO];
|
||||
[tf setAlignment: NSCenterTextAlignment];
|
||||
[tf setFrame: frame];
|
||||
[self addSubview: tf];
|
||||
[tf setStringValue: [_EO title]];
|
||||
[self editTextField: tf
|
||||
withEvent: theEvent];
|
||||
[_EO setTitle: [tf stringValue]];
|
||||
[tf removeFromSuperview];
|
||||
RELEASE(tf);
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName: IBSelectionChangedNotification
|
||||
object: self];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// the following code did job that is now done by GormInternalViewEditor
|
||||
|
||||
// // are we on the knob of a selected view ?
|
||||
// {
|
||||
// int count = [selection count];
|
||||
// int i;
|
||||
// GormViewEditor *knobView = nil;
|
||||
// IBKnobPosition knob = IBNoneKnobPosition;
|
||||
// NSPoint mouseDownPoint;
|
||||
|
||||
// for ( i = 0; i < count; i++ )
|
||||
// {
|
||||
// mouseDownPoint = [[[selection objectAtIndex: i] superview]
|
||||
// convertPoint: [theEvent locationInWindow]
|
||||
// fromView: nil];
|
||||
|
||||
// knob = GormKnobHitInRect([[selection objectAtIndex: i] frame],
|
||||
// mouseDownPoint);
|
||||
|
||||
// if (knob != IBNoneKnobPosition)
|
||||
// {
|
||||
// knobView = [selection objectAtIndex: i];
|
||||
// [self selectObjects: [NSMutableArray arrayWithObject: knobView]];
|
||||
// // we should set knobView as the only view selected
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
// NSLog(@"md %@ openedSubeditor %@", self, openedSubeditor);
|
||||
// if ( openedSubeditor != nil )
|
||||
// {
|
||||
// mouseDownPoint = [[openedSubeditor superview]
|
||||
// convertPoint: [theEvent locationInWindow]
|
||||
// fromView: nil];
|
||||
|
||||
// NSLog(@"md %@ %@ %@", self, NSStringFromPoint(mouseDownPoint),
|
||||
// NSStringFromRect([openedSubeditor frame]));
|
||||
|
||||
// knob = GormKnobHitInRect([openedSubeditor frame],
|
||||
// mouseDownPoint);
|
||||
// if (knob != IBNoneKnobPosition)
|
||||
// {
|
||||
// NSLog(@"md %@ on knob !", self);
|
||||
// knobView = openedSubeditor;
|
||||
// // we should take back the selection
|
||||
// // we should select openedSubeditor only
|
||||
// [self selectObjects: [NSMutableArray arrayWithObject: knobView]];
|
||||
// [[self window] disableFlushWindow];
|
||||
// [self display];
|
||||
// [[self window] enableFlushWindow];
|
||||
// [[self window] flushWindow];
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// if (knobView != nil)
|
||||
// {
|
||||
// [self handleMouseOnKnob: knob
|
||||
// ofView: knobView
|
||||
// withEvent: theEvent];
|
||||
// // NSLog(@"resize %@", knobView);
|
||||
// [self setNeedsDisplay: YES];
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// {
|
||||
// GormViewEditor *editorView;
|
||||
|
||||
// // get the view we are on
|
||||
// {
|
||||
// NSPoint mouseDownPoint;
|
||||
// NSView *result;
|
||||
|
||||
|
||||
// mouseDownPoint = [self convertPoint: [theEvent locationInWindow]
|
||||
// fromView: nil];
|
||||
|
||||
// result = [_editedObject hitTest: mouseDownPoint];
|
||||
|
||||
|
||||
// NSLog(@"md %@ result %@", self, result);
|
||||
// // we should get a result which is a direct subeditor
|
||||
// {
|
||||
// id temp = result;
|
||||
// GormViewEditor *parent = [document parentEditorForEditor: temp];
|
||||
|
||||
// NSLog(@"md %@ parent %@", self, parent);
|
||||
// while ((temp != nil) && (parent != self) && (temp != self))
|
||||
// {
|
||||
// NSLog(@"md %@ temp = %@", self, temp);
|
||||
// temp = [temp superview];
|
||||
// while (![temp isKindOfClass: [GormViewEditor class]])
|
||||
// {
|
||||
// NSLog(@"md %@ temp = %@", self, temp);
|
||||
// temp = [temp superview];
|
||||
// }
|
||||
// NSLog(@"md %@ temp = %@", self, temp);
|
||||
// parent = [document parentEditorForEditor: temp];
|
||||
// }
|
||||
// NSLog(@"md %@ temp = %@", self, temp);
|
||||
// if (temp != nil)
|
||||
// {
|
||||
// result = temp;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// NSLog(@"WARNING -- strange case");
|
||||
// result = self;
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// if ([result isKindOfClass: [GormViewEditor class]])
|
||||
// {
|
||||
// /*
|
||||
// if (result != self)
|
||||
// {
|
||||
// [self selectObjects: [NSMutableArray arrayWithObject: result]];
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// [self selectObjects: [NSMutableArray array]];
|
||||
// }
|
||||
// [[self window] disableFlushWindow];
|
||||
// [self display];
|
||||
// [[self window] enableFlushWindow];
|
||||
// [[self window] flushWindow];
|
||||
// NSLog(@"clicked on %@", result);
|
||||
// */
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// NSLog(@"md %@ result = nil", self);
|
||||
// result = nil;
|
||||
// }
|
||||
|
||||
// editorView = result;
|
||||
// }
|
||||
|
||||
// if (([theEvent clickCount] == 2)
|
||||
// && [editorView respondsToSelector: @selector(canBeOpened)]
|
||||
// && ([editorView canBeOpened] == YES)
|
||||
// && (editorView != self))
|
||||
|
||||
// {
|
||||
// [editorView setOpened: YES];
|
||||
// [self silentlyResetSelection];
|
||||
// openedSubeditor = editorView;
|
||||
// [self setNeedsDisplay: YES];
|
||||
// NSLog(@"md %@ editor should open", self);
|
||||
// return;
|
||||
// }
|
||||
|
||||
// if (editorView != self)
|
||||
// [self handleMouseOnView: editorView
|
||||
// withEvent: theEvent];
|
||||
// else // editorView == self
|
||||
// {
|
||||
// [self selectObjects: [NSMutableArray array]];
|
||||
// [self setNeedsDisplay: YES];
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
|
||||
/*
|
||||
// are we on a selected view ?
|
||||
{
|
||||
int count = [selection count];
|
||||
int i;
|
||||
BOOL inView = NO;
|
||||
NSPoint mouseDownPoint;
|
||||
|
||||
|
||||
for ( i = 0; i < count; i++ )
|
||||
{
|
||||
mouseDownPoint = [[[selection objectAtIndex: i] superview]
|
||||
convertPoint: [theEvent locationInWindow]
|
||||
fromView: nil];
|
||||
|
||||
if ([[[selection objectAtIndex: i] superview]
|
||||
mouse: mouseDownPoint
|
||||
inRect: [[selection objectAtIndex: i] frame]])
|
||||
{
|
||||
inView = YES;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (inView)
|
||||
{
|
||||
NSLog(@"inside %@", [selection objectAtIndex: i]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
*/
|
||||
// are we on a view ?
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
- (unsigned) draggingEntered: (id<NSDraggingInfo>)sender
|
||||
{
|
||||
NSRect rect = [[_EO contentView] bounds];
|
||||
NSPoint loc = [sender draggingLocation];
|
||||
loc = [[_EO contentView]
|
||||
convertPoint: loc fromView: nil];
|
||||
|
||||
if (NSMouseInRect(loc, [[_EO contentView] bounds], NO) == NO)
|
||||
{
|
||||
return NSDragOperationNone;
|
||||
}
|
||||
else
|
||||
{
|
||||
rect.origin.x += 2;
|
||||
rect.origin.y += 2;
|
||||
rect.size.width -= 4;
|
||||
rect.size.height -= 4;
|
||||
|
||||
[[_EO contentView] lockFocus];
|
||||
|
||||
[[NSColor darkGrayColor] set];
|
||||
NSFrameRectWithWidth(rect, 2);
|
||||
|
||||
[[_EO contentView] unlockFocus];
|
||||
[[self window] flushWindow];
|
||||
return NSDragOperationCopy;
|
||||
}
|
||||
}
|
||||
|
||||
- (void) draggingExited: (id<NSDraggingInfo>)sender
|
||||
{
|
||||
NSRect rect = [[_EO contentView] bounds];
|
||||
rect.origin.x += 2;
|
||||
rect.origin.y += 2;
|
||||
rect.size.width -= 4;
|
||||
rect.size.height -= 4;
|
||||
|
||||
rect.origin.x --;
|
||||
rect.size.width ++;
|
||||
rect.size.height ++;
|
||||
|
||||
[[self window] disableFlushWindow];
|
||||
[self displayRect:
|
||||
[[_EO contentView] convertRect: rect
|
||||
toView: self]];
|
||||
[[self window] enableFlushWindow];
|
||||
[[self window] flushWindow];
|
||||
}
|
||||
|
||||
- (unsigned int) draggingUpdated: (id<NSDraggingInfo>)sender
|
||||
{
|
||||
NSPoint loc = [sender draggingLocation];
|
||||
NSRect rect = [[_EO contentView] bounds];
|
||||
loc = [[_EO contentView]
|
||||
convertPoint: loc fromView: nil];
|
||||
|
||||
rect.origin.x += 2;
|
||||
rect.origin.y += 2;
|
||||
rect.size.width -= 4;
|
||||
rect.size.height -= 4;
|
||||
|
||||
if (NSMouseInRect(loc, [[_EO contentView] bounds], NO) == NO)
|
||||
{
|
||||
[[self window] disableFlushWindow];
|
||||
rect.origin.x --;
|
||||
rect.size.width ++;
|
||||
rect.size.height ++;
|
||||
[self displayRect:
|
||||
[[_EO contentView] convertRect: rect
|
||||
toView: self]];
|
||||
[[self window] enableFlushWindow];
|
||||
[[self window] flushWindow];
|
||||
return NSDragOperationNone;
|
||||
}
|
||||
else
|
||||
{
|
||||
[[_EO contentView] lockFocus];
|
||||
|
||||
[[NSColor darkGrayColor] set];
|
||||
NSFrameRectWithWidth(rect, 2);
|
||||
|
||||
[[_EO contentView] unlockFocus];
|
||||
[[self window] flushWindow];
|
||||
return NSDragOperationCopy;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (BOOL) prepareForDragOperation: (id<NSDraggingInfo>)sender
|
||||
{
|
||||
NSString *dragType;
|
||||
NSArray *types;
|
||||
NSPasteboard *dragPb;
|
||||
|
||||
NSLog(@"prepareForDragOperation called");
|
||||
|
||||
dragPb = [sender draggingPasteboard];
|
||||
|
||||
types = [dragPb types];
|
||||
|
||||
if ([types containsObject: IBViewPboardType] == YES)
|
||||
{
|
||||
dragType = IBViewPboardType;
|
||||
}
|
||||
else if ([types containsObject: GormLinkPboardType] == YES)
|
||||
{
|
||||
dragType = GormLinkPboardType;
|
||||
}
|
||||
else if ([types containsObject: IBFormatterPboardType] == YES)
|
||||
{
|
||||
dragType = IBFormatterPboardType;
|
||||
}
|
||||
else
|
||||
{
|
||||
dragType = nil;
|
||||
}
|
||||
|
||||
if (dragType == IBViewPboardType)
|
||||
{
|
||||
/*
|
||||
* We can accept views dropped anywhere.
|
||||
*/
|
||||
NSPoint loc = [sender draggingLocation];
|
||||
loc = [[_EO contentView]
|
||||
convertPoint: loc fromView: nil];
|
||||
if (NSMouseInRect(loc, [_EO bounds], NO) == NO)
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL) performDragOperation: (id<NSDraggingInfo>)sender
|
||||
{
|
||||
NSString *dragType;
|
||||
NSPasteboard *dragPb;
|
||||
NSArray *types;
|
||||
|
||||
dragPb = [sender draggingPasteboard];
|
||||
|
||||
types = [dragPb types];
|
||||
|
||||
if ([types containsObject: IBViewPboardType] == YES)
|
||||
{
|
||||
dragType = IBViewPboardType;
|
||||
}
|
||||
else if ([types containsObject: GormLinkPboardType] == YES)
|
||||
{
|
||||
dragType = GormLinkPboardType;
|
||||
}
|
||||
else if ([types containsObject: IBFormatterPboardType] == YES)
|
||||
{
|
||||
dragType = IBFormatterPboardType;
|
||||
}
|
||||
else
|
||||
{
|
||||
dragType = nil;
|
||||
}
|
||||
|
||||
if (dragType == IBViewPboardType)
|
||||
{
|
||||
NSPoint loc = [sender draggingLocation];
|
||||
NSArray *views;
|
||||
// NSArray *array = [NSMutableArray array];
|
||||
NSEnumerator *enumerator;
|
||||
NSView *sub;
|
||||
|
||||
/*
|
||||
if (opened != YES)
|
||||
{
|
||||
NSLog(@"make ourself the editor");
|
||||
}
|
||||
else if (openedSubeditor != nil)
|
||||
{
|
||||
NSLog(@"close our subeditors");
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
* Ask the document to get the dragged views from the pasteboard and add
|
||||
* them to it's collection of known objects.
|
||||
*/
|
||||
views = [document pasteType: IBViewPboardType
|
||||
fromPasteboard: dragPb
|
||||
parent: _EO];
|
||||
/*
|
||||
* Now make all the views subviews of ourself, setting their origin to
|
||||
* be the point at which they were dropped (converted from window
|
||||
* coordinates to our own coordinates).
|
||||
*/
|
||||
loc = [[_EO contentView]
|
||||
convertPoint: loc fromView: nil];
|
||||
if (NSMouseInRect(loc, [_EO bounds], NO) == NO)
|
||||
{
|
||||
// Dropped outside our view frame
|
||||
NSLog(@"Dropped outside current edit view");
|
||||
dragType = nil;
|
||||
return NO;
|
||||
}
|
||||
enumerator = [views objectEnumerator];
|
||||
while ((sub = [enumerator nextObject]) != nil)
|
||||
{
|
||||
NSRect rect = [sub frame];
|
||||
|
||||
rect.origin = [[_EO contentView]
|
||||
convertPoint: [sender draggedImageLocation]
|
||||
fromView: nil];
|
||||
rect.origin.x = (int) rect.origin.x;
|
||||
rect.origin.y = (int) rect.origin.y;
|
||||
rect.size.width = (int) rect.size.width;
|
||||
rect.size.height = (int) rect.size.height;
|
||||
[sub setFrame: rect];
|
||||
|
||||
[[_EO contentView] addSubview: sub];
|
||||
|
||||
[self selectObjects:
|
||||
[NSArray arrayWithObject:
|
||||
[document editorForObject: sub
|
||||
inEditor: self
|
||||
create: YES]]];
|
||||
}
|
||||
// FIXME we should maybe open ourself
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
// - (void) pasteInSelection
|
||||
// {
|
||||
// [self pasteInView: [_EO contentView]];
|
||||
// }
|
||||
|
||||
- (NSArray *)destroyAndListSubviews
|
||||
{
|
||||
if (contentViewEditor)
|
||||
{
|
||||
return [contentViewEditor destroyAndListSubviews];
|
||||
}
|
||||
else
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
30
GormButtonEditor.h
Normal file
30
GormButtonEditor.h
Normal file
|
@ -0,0 +1,30 @@
|
|||
/* GormButtonEditor.h - Editor for buttons.
|
||||
*
|
||||
* Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
*
|
||||
* Author: Pierre-Yves Rivaille
|
||||
* Date: Aug 2002
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#import "GormControlEditor.h"
|
||||
|
||||
@interface GormButtonEditor : GormControlEditor
|
||||
{
|
||||
}
|
||||
@end
|
336
GormButtonEditor.m
Normal file
336
GormButtonEditor.m
Normal file
|
@ -0,0 +1,336 @@
|
|||
/* GormButtonEditor.m
|
||||
*
|
||||
* Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
*
|
||||
* Author: Pierre-Yves Rivaille <pyrivail@ens-lyon.fr>
|
||||
* Date: 2002
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#import <AppKit/AppKit.h>
|
||||
|
||||
#include "GormPrivate.h"
|
||||
|
||||
#import "GormButtonEditor.h"
|
||||
|
||||
#import "GormViewWithSubviewsEditor.h"
|
||||
|
||||
#define _EO ((NSButton *)_editedObject)
|
||||
|
||||
@implementation NSButton (GormObjectAdditions)
|
||||
- (NSString*) editorClassName
|
||||
{
|
||||
return @"GormButtonEditor";
|
||||
}
|
||||
@end
|
||||
|
||||
@interface NSButtonCell (GormObjectAdditions)
|
||||
- (NSRect) gormTitleRectForFrame: (NSRect) cellFrame
|
||||
inView: (NSView *)controlView;
|
||||
@end
|
||||
@implementation NSButtonCell (GormObjectAdditions)
|
||||
- (NSRect) gormTitleRectForFrame: (NSRect) cellFrame
|
||||
inView: (NSView *)controlView
|
||||
{
|
||||
unsigned mask;
|
||||
NSImage *imageToDisplay;
|
||||
NSRect imageRect;
|
||||
NSString *titleToDisplay;
|
||||
NSRect titleRect;
|
||||
NSSize imageSize = {0, 0};
|
||||
NSSize titleSize = {0, 0};
|
||||
NSColor *backgroundColor = nil;
|
||||
BOOL flippedView = [controlView isFlipped];
|
||||
NSCellImagePosition ipos = _cell.image_position;
|
||||
|
||||
// // transparent buttons never draw
|
||||
// if (_buttoncell_is_transparent)
|
||||
// return;
|
||||
|
||||
cellFrame = [self drawingRectForBounds: cellFrame];
|
||||
|
||||
if (_cell.is_highlighted)
|
||||
{
|
||||
mask = _highlightsByMask;
|
||||
|
||||
if (_cell.state)
|
||||
mask &= ~_showAltStateMask;
|
||||
}
|
||||
else if (_cell.state)
|
||||
mask = _showAltStateMask;
|
||||
else
|
||||
mask = NSNoCellMask;
|
||||
|
||||
/* Pushed in buttons contents are displaced to the bottom right 1px. */
|
||||
if (_cell.is_bordered && (mask & NSPushInCellMask))
|
||||
{
|
||||
cellFrame = NSOffsetRect(cellFrame, 1., flippedView ? 1. : -1.);
|
||||
}
|
||||
|
||||
/* Determine the background color. */
|
||||
if (mask & (NSChangeGrayCellMask | NSChangeBackgroundCellMask))
|
||||
{
|
||||
backgroundColor = [NSColor selectedControlColor];
|
||||
}
|
||||
|
||||
if (backgroundColor == nil)
|
||||
backgroundColor = [NSColor controlBackgroundColor];
|
||||
|
||||
/* Draw the cell's background color.
|
||||
We draw when there is a border or when highlightsByMask
|
||||
is NSChangeBackgroundCellMask or NSChangeGrayCellMask,
|
||||
as required by our nextstep-like look and feel. */
|
||||
if (_cell.is_bordered
|
||||
|| (_highlightsByMask & NSChangeBackgroundCellMask)
|
||||
|| (_highlightsByMask & NSChangeGrayCellMask))
|
||||
{
|
||||
// [backgroundColor set];
|
||||
// NSRectFill (cellFrame);
|
||||
}
|
||||
|
||||
/*
|
||||
* Determine the image and the title that will be
|
||||
* displayed. If the NSContentsCellMask is set the
|
||||
* image and title are swapped only if state is 1 or
|
||||
* if highlighting is set (when a button is pushed it's
|
||||
* content is changed to the face of reversed state).
|
||||
*/
|
||||
if (mask & NSContentsCellMask)
|
||||
{
|
||||
imageToDisplay = _altImage;
|
||||
if (!imageToDisplay)
|
||||
imageToDisplay = _cell_image;
|
||||
titleToDisplay = _altContents;
|
||||
if (titleToDisplay == nil || [titleToDisplay isEqual: @""])
|
||||
titleToDisplay = _contents;
|
||||
}
|
||||
else
|
||||
{
|
||||
imageToDisplay = _cell_image;
|
||||
titleToDisplay = _contents;
|
||||
}
|
||||
|
||||
if (imageToDisplay)
|
||||
{
|
||||
/* FIXME - the following is a hack! Because we don't seem to be
|
||||
getting alpha composing of images right, we use this hack of
|
||||
hard-setting manually the background color of the image to
|
||||
the wanted background color ... this should go away when
|
||||
alpha composing of images works 100%. */
|
||||
// [imageToDisplay setBackgroundColor: backgroundColor];
|
||||
imageSize = [imageToDisplay size];
|
||||
}
|
||||
|
||||
// if (titleToDisplay && (ipos == NSImageAbove || ipos == NSImageBelow))
|
||||
// {
|
||||
titleSize = [self _sizeText: titleToDisplay];
|
||||
// }
|
||||
|
||||
if (flippedView == YES)
|
||||
{
|
||||
if (ipos == NSImageAbove)
|
||||
{
|
||||
ipos = NSImageBelow;
|
||||
}
|
||||
else if (ipos == NSImageBelow)
|
||||
{
|
||||
ipos = NSImageAbove;
|
||||
}
|
||||
}
|
||||
|
||||
switch (ipos)
|
||||
{
|
||||
case NSNoImage:
|
||||
imageToDisplay = nil;
|
||||
titleRect = cellFrame;
|
||||
{
|
||||
int heightDiff = titleRect.size.height - titleSize.height;
|
||||
titleRect.origin.y += heightDiff - heightDiff / 2;
|
||||
titleRect.size.height -= heightDiff;
|
||||
}
|
||||
break;
|
||||
|
||||
case NSImageOnly:
|
||||
titleToDisplay = nil;
|
||||
imageRect = cellFrame;
|
||||
break;
|
||||
|
||||
case NSImageLeft:
|
||||
imageRect.origin = cellFrame.origin;
|
||||
imageRect.size.width = imageSize.width;
|
||||
imageRect.size.height = cellFrame.size.height;
|
||||
if (_cell.is_bordered || _cell.is_bezeled)
|
||||
{
|
||||
imageRect.origin.x += 3;
|
||||
imageRect.size.height -= 2;
|
||||
imageRect.origin.y += 1;
|
||||
}
|
||||
titleRect = imageRect;
|
||||
titleRect.origin.x += imageSize.width + xDist;
|
||||
titleRect.size.width = cellFrame.size.width - imageSize.width - xDist;
|
||||
if (_cell.is_bordered || _cell.is_bezeled)
|
||||
{
|
||||
titleRect.size.width -= 3;
|
||||
}
|
||||
{
|
||||
int heightDiff = titleRect.size.height - titleSize.height;
|
||||
titleRect.origin.y += heightDiff - heightDiff / 2;
|
||||
titleRect.size.height -= heightDiff;
|
||||
}
|
||||
break;
|
||||
|
||||
case NSImageRight:
|
||||
imageRect.origin.x = NSMaxX(cellFrame) - imageSize.width;
|
||||
imageRect.origin.y = cellFrame.origin.y;
|
||||
imageRect.size.width = imageSize.width;
|
||||
imageRect.size.height = cellFrame.size.height;
|
||||
if (_cell.is_bordered || _cell.is_bezeled)
|
||||
{
|
||||
imageRect.origin.x -= 3;
|
||||
imageRect.size.height -= 2;
|
||||
imageRect.origin.y += 1;
|
||||
}
|
||||
titleRect.origin = cellFrame.origin;
|
||||
titleRect.size.width = cellFrame.size.width - imageSize.width - xDist;
|
||||
titleRect.size.height = cellFrame.size.height;
|
||||
if (_cell.is_bordered || _cell.is_bezeled)
|
||||
{
|
||||
titleRect.origin.x += 3;
|
||||
titleRect.size.width -= 3;
|
||||
}
|
||||
{
|
||||
int heightDiff = titleRect.size.height - titleSize.height;
|
||||
titleRect.origin.y += heightDiff - heightDiff / 2;
|
||||
titleRect.size.height -= heightDiff;
|
||||
}
|
||||
break;
|
||||
|
||||
case NSImageAbove:
|
||||
/*
|
||||
* In this case, imageRect is all the space we can allocate
|
||||
* above the text.
|
||||
* The drawing code below will then center the image in imageRect.
|
||||
*/
|
||||
titleRect.origin.x = cellFrame.origin.x;
|
||||
titleRect.origin.y = cellFrame.origin.y;
|
||||
titleRect.size.width = cellFrame.size.width;
|
||||
titleRect.size.height = titleSize.height;
|
||||
|
||||
imageRect.origin.x = cellFrame.origin.x;
|
||||
imageRect.origin.y = cellFrame.origin.y;
|
||||
imageRect.origin.y += titleRect.size.height + yDist;
|
||||
imageRect.size.width = cellFrame.size.width;
|
||||
imageRect.size.height = cellFrame.size.height;
|
||||
imageRect.size.height -= titleSize.height + yDist;
|
||||
|
||||
if (_cell.is_bordered || _cell.is_bezeled)
|
||||
{
|
||||
imageRect.size.width -= 6;
|
||||
imageRect.origin.x += 3;
|
||||
titleRect.size.width -= 6;
|
||||
titleRect.origin.x += 3;
|
||||
imageRect.size.height -= 1;
|
||||
titleRect.size.height -= 1;
|
||||
// titleRect.origin.y += 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case NSImageBelow:
|
||||
/*
|
||||
* In this case, imageRect is all the space we can allocate
|
||||
* below the text.
|
||||
* The drawing code below will then center the image in imageRect.
|
||||
*/
|
||||
titleRect.origin.x = cellFrame.origin.x;
|
||||
titleRect.origin.y = cellFrame.origin.y + cellFrame.size.height;
|
||||
titleRect.origin.y -= titleSize.height;
|
||||
titleRect.size.width = cellFrame.size.width;
|
||||
titleRect.size.height = titleSize.height;
|
||||
|
||||
imageRect.origin.x = cellFrame.origin.x;
|
||||
imageRect.origin.y = cellFrame.origin.y;
|
||||
imageRect.size.width = cellFrame.size.width;
|
||||
imageRect.size.height = cellFrame.size.height;
|
||||
imageRect.size.height -= titleSize.height + yDist;
|
||||
|
||||
if (_cell.is_bordered || _cell.is_bezeled)
|
||||
{
|
||||
imageRect.size.width -= 6;
|
||||
imageRect.origin.x += 3;
|
||||
titleRect.size.width -= 6;
|
||||
titleRect.origin.x += 3;
|
||||
imageRect.size.height -= 1;
|
||||
imageRect.origin.y += 1;
|
||||
// titleRect.size.height -= 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case NSImageOverlaps:
|
||||
titleRect = cellFrame;
|
||||
imageRect = cellFrame;
|
||||
{
|
||||
int heightDiff = titleRect.size.height - titleSize.height;
|
||||
titleRect.origin.y += heightDiff - heightDiff / 2;
|
||||
titleRect.size.height -= heightDiff;
|
||||
}
|
||||
// TODO: Add distance from border if needed
|
||||
break;
|
||||
}
|
||||
|
||||
return titleRect;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation GormButtonEditor
|
||||
- (void) mouseDown: (NSEvent*)theEvent
|
||||
{
|
||||
if (([theEvent clickCount] == 2) && [parent isOpened])
|
||||
// double-clicked -> let's edit
|
||||
{
|
||||
NSTextField *tf =
|
||||
[[NSTextField alloc] initWithFrame: [self bounds]];
|
||||
NSRect frame = [[_EO cell]
|
||||
gormTitleRectForFrame: [_EO frame]
|
||||
inView: _EO];
|
||||
frame.origin.y -= 2;
|
||||
frame.size.height += 4;
|
||||
[tf setFrame: frame];
|
||||
[tf setEditable: YES];
|
||||
[tf setBezeled: NO];
|
||||
[tf setBordered: YES];
|
||||
[tf setAlignment: [_EO alignment]];
|
||||
[tf setFont: [_EO font]];
|
||||
[self addSubview: tf];
|
||||
[tf setStringValue: [_EO stringValue]];
|
||||
[self editTextField: tf
|
||||
withEvent: theEvent];
|
||||
[_EO setStringValue: [tf stringValue]];
|
||||
[tf removeFromSuperview];
|
||||
RELEASE(tf);
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName: IBSelectionChangedNotification
|
||||
object: parent];
|
||||
}
|
||||
else
|
||||
{
|
||||
[super mouseDown: theEvent];
|
||||
}
|
||||
}
|
||||
@end
|
|
@ -64,6 +64,10 @@
|
|||
- (void) makeSelectionVisible: (BOOL)flag
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
- (void) selectObjects: (NSArray*)objects
|
||||
{
|
||||
}
|
||||
@end
|
||||
|
||||
|
|
|
@ -145,7 +145,7 @@ NSString *IBClassNameChangedNotification = @"IBClassNameChangedNotification";
|
|||
|| [classInformation objectForKey: superClassName] != nil)
|
||||
{
|
||||
NSMutableDictionary *classInfo;
|
||||
NSString *newClassName;
|
||||
// NSString *newClassName;
|
||||
|
||||
if(![classInformation objectForKey: className])
|
||||
{
|
||||
|
|
29
GormControlEditor.h
Normal file
29
GormControlEditor.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
/* GormControlEditor.h
|
||||
*
|
||||
* Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
*
|
||||
* Author: Pierre-Yves Rivaille <pyrivail@ens-lyon.fr>
|
||||
* Date: 2002
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#import "GormViewEditor.h"
|
||||
|
||||
@interface GormControlEditor : GormViewEditor
|
||||
|
||||
@end
|
553
GormControlEditor.m
Normal file
553
GormControlEditor.m
Normal file
|
@ -0,0 +1,553 @@
|
|||
/* GormControlEditor.m
|
||||
*
|
||||
* Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
*
|
||||
* Author: Pierre-Yves Rivaille <pyrivail@ens-lyon.fr>
|
||||
* Date: 2002
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#import <AppKit/AppKit.h>
|
||||
|
||||
#include "GormPrivate.h"
|
||||
|
||||
#import "GormViewWithSubviewsEditor.h"
|
||||
#import "GormControlEditor.h"
|
||||
|
||||
#import "GormPlacementInfo.h"
|
||||
|
||||
#define _EO ((NSControl *)_editedObject)
|
||||
|
||||
@class GormWindowEditor;
|
||||
|
||||
@implementation NSControl (GormObjectAdditions)
|
||||
- (NSString*) editorClassName
|
||||
{
|
||||
return @"GormControlEditor";
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
@interface GormViewEditor (Private)
|
||||
- (void) _displayFrameWithHint: (NSRect) frame
|
||||
withPlacementInfo: (GormPlacementInfo*)gpi;
|
||||
- (void) _initializeHintWithInfo: (GormPlacementInfo*) gpi;
|
||||
@end
|
||||
|
||||
@interface GormControlEditor (IntelligentPlacement)
|
||||
- (void) _altDisplayFrame: (NSRect) frame
|
||||
withPlacementInfo: (GormPlacementInfo*)gpi;
|
||||
- (void) _displayFrame: (NSRect) frame
|
||||
withPlacementInfo: (GormPlacementInfo*) gpi;
|
||||
@end
|
||||
|
||||
@implementation GormControlEditor
|
||||
|
||||
|
||||
// - (GormPlacementInfo *) initializeResizingInFrame: (NSView *)view
|
||||
// withKnob: (IBKnobPosition) knob
|
||||
// {
|
||||
// GormPlacementInfo *gip;
|
||||
// gip = [super initializeResizingInFrame: view withKnob: knob];
|
||||
// }
|
||||
|
||||
|
||||
- (void) _altDisplayFrame: (NSRect) frame
|
||||
withPlacementInfo: (GormPlacementInfo*)gpi
|
||||
{
|
||||
NSSize size = [self frame].size;
|
||||
NSSize constrainedSize;
|
||||
int col;
|
||||
int row;
|
||||
|
||||
if (gpi->firstPass == NO)
|
||||
[gpi->resizingIn displayRect: gpi->oldRect];
|
||||
else
|
||||
gpi->firstPass = NO;
|
||||
|
||||
col = frame.size.width / size.width;
|
||||
row = frame.size.height / size.height;
|
||||
|
||||
if (col < 1) col = 1;
|
||||
if (row < 1) row = 1;
|
||||
|
||||
constrainedSize.width = col * size.width;
|
||||
constrainedSize.height = row * size.height;
|
||||
|
||||
switch (gpi->knob)
|
||||
{
|
||||
case IBBottomLeftKnobPosition:
|
||||
case IBMiddleLeftKnobPosition:
|
||||
case IBTopLeftKnobPosition:
|
||||
frame.origin.x = NSMaxX(frame) - constrainedSize.width;
|
||||
frame.size.width = constrainedSize.width;
|
||||
break;
|
||||
case IBTopRightKnobPosition:
|
||||
case IBMiddleRightKnobPosition:
|
||||
case IBBottomRightKnobPosition:
|
||||
frame.size.width = constrainedSize.width;
|
||||
break;
|
||||
case IBTopMiddleKnobPosition:
|
||||
case IBBottomMiddleKnobPosition:
|
||||
case IBNoneKnobPosition:
|
||||
break;
|
||||
}
|
||||
|
||||
switch (gpi->knob)
|
||||
{
|
||||
case IBBottomLeftKnobPosition:
|
||||
case IBBottomRightKnobPosition:
|
||||
case IBBottomMiddleKnobPosition:
|
||||
frame.origin.y = NSMaxY(frame) - constrainedSize.height;
|
||||
frame.size.height = constrainedSize.height;
|
||||
break;
|
||||
case IBTopMiddleKnobPosition:
|
||||
case IBTopRightKnobPosition:
|
||||
case IBTopLeftKnobPosition:
|
||||
frame.size.height = constrainedSize.height;
|
||||
break;
|
||||
case IBMiddleLeftKnobPosition:
|
||||
case IBMiddleRightKnobPosition:
|
||||
case IBNoneKnobPosition:
|
||||
break;
|
||||
}
|
||||
|
||||
GormShowFrameWithKnob(frame, gpi->knob);
|
||||
gpi->lastFrame = frame;
|
||||
|
||||
gpi->oldRect = GormExtBoundsForRect(frame);
|
||||
gpi->oldRect.origin.x--;
|
||||
gpi->oldRect.origin.y--;
|
||||
gpi->oldRect.size.width += 2;
|
||||
gpi->oldRect.size.height += 2;
|
||||
}
|
||||
|
||||
- (void) _displayFrame: (NSRect) frame
|
||||
withPlacementInfo: (GormPlacementInfo*) gpi
|
||||
{
|
||||
NSSize minSize;
|
||||
|
||||
if (gpi->firstPass == NO)
|
||||
[gpi->resizingIn displayRect: gpi->oldRect];
|
||||
else
|
||||
gpi->firstPass = NO;
|
||||
|
||||
minSize = [[_EO cell] cellSize];
|
||||
|
||||
if (frame.size.width < minSize.width)
|
||||
{
|
||||
switch (gpi->knob)
|
||||
{
|
||||
case IBBottomLeftKnobPosition:
|
||||
case IBMiddleLeftKnobPosition:
|
||||
case IBTopLeftKnobPosition:
|
||||
frame.origin.x = NSMaxX([self frame]) - minSize.width;
|
||||
frame.size.width = minSize.width;
|
||||
break;
|
||||
case IBTopRightKnobPosition:
|
||||
case IBMiddleRightKnobPosition:
|
||||
case IBBottomRightKnobPosition:
|
||||
frame.size.width = minSize.width;
|
||||
break;
|
||||
case IBTopMiddleKnobPosition:
|
||||
case IBBottomMiddleKnobPosition:
|
||||
case IBNoneKnobPosition:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (frame.size.height < minSize.height)
|
||||
{
|
||||
switch (gpi->knob)
|
||||
{
|
||||
case IBBottomLeftKnobPosition:
|
||||
case IBBottomRightKnobPosition:
|
||||
case IBBottomMiddleKnobPosition:
|
||||
frame.origin.y = NSMaxY([self frame]) - minSize.height;
|
||||
frame.size.height = minSize.height;
|
||||
break;
|
||||
case IBTopMiddleKnobPosition:
|
||||
case IBTopRightKnobPosition:
|
||||
case IBTopLeftKnobPosition:
|
||||
frame.size.height = minSize.height;
|
||||
break;
|
||||
case IBMiddleLeftKnobPosition:
|
||||
case IBMiddleRightKnobPosition:
|
||||
case IBNoneKnobPosition:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
GormShowFrameWithKnob(frame, gpi->knob);
|
||||
gpi->lastFrame = frame;
|
||||
|
||||
gpi->oldRect = GormExtBoundsForRect(frame);
|
||||
gpi->oldRect.origin.x--;
|
||||
gpi->oldRect.origin.y--;
|
||||
gpi->oldRect.size.width += 2;
|
||||
gpi->oldRect.size.height += 2;
|
||||
}
|
||||
|
||||
- (void) _displayFrameWithHint: (NSRect) frame
|
||||
withPlacementInfo: (GormPlacementInfo*)gpi
|
||||
{
|
||||
float leftOfFrame = NSMinX(frame);
|
||||
float rightOfFrame = NSMaxX(frame);
|
||||
float topOfFrame = NSMaxY(frame);
|
||||
float bottomOfFrame = NSMinY(frame);
|
||||
int i;
|
||||
int count;
|
||||
int lastDistance;
|
||||
int minimum = 10;
|
||||
NSMutableArray *bests;
|
||||
if (gpi->hintInitialized == NO)
|
||||
{
|
||||
[self _initializeHintWithInfo: gpi];
|
||||
}
|
||||
|
||||
{
|
||||
if (gpi->firstPass == NO)
|
||||
[gpi->resizingIn displayRect: gpi->oldRect];
|
||||
else
|
||||
gpi->firstPass = NO;
|
||||
}
|
||||
{
|
||||
[gpi->resizingIn setNeedsDisplayInRect: gpi->lastLeftRect];
|
||||
[[self window] displayIfNeeded];
|
||||
gpi->lastLeftRect = NSZeroRect;
|
||||
}
|
||||
{
|
||||
[gpi->resizingIn setNeedsDisplayInRect: gpi->lastRightRect];
|
||||
[[self window] displayIfNeeded];
|
||||
gpi->lastRightRect = NSZeroRect;
|
||||
}
|
||||
{
|
||||
[gpi->resizingIn setNeedsDisplayInRect: gpi->lastTopRect];
|
||||
[[self window] displayIfNeeded];
|
||||
gpi->lastTopRect = NSZeroRect;
|
||||
}
|
||||
{
|
||||
[gpi->resizingIn setNeedsDisplayInRect: gpi->lastBottomRect];
|
||||
[[self window] displayIfNeeded];
|
||||
gpi->lastBottomRect = NSZeroRect;
|
||||
}
|
||||
|
||||
|
||||
if (gpi->knob == IBTopLeftKnobPosition
|
||||
|| gpi->knob == IBMiddleLeftKnobPosition
|
||||
|| gpi->knob == IBBottomLeftKnobPosition)
|
||||
{
|
||||
bests = [NSMutableArray arrayWithCapacity: 4];
|
||||
minimum = 10;
|
||||
count = [gpi->leftHints count];
|
||||
for ( i = 0; i < count; i++ )
|
||||
{
|
||||
lastDistance = [[gpi->leftHints objectAtIndex: i]
|
||||
distanceToFrame: frame];
|
||||
if (lastDistance < minimum)
|
||||
{
|
||||
bests = [NSMutableArray arrayWithCapacity: 4];
|
||||
[bests addObject: [gpi->leftHints objectAtIndex: i]];
|
||||
minimum = lastDistance;
|
||||
}
|
||||
else if (lastDistance == minimum)
|
||||
[bests addObject: [gpi->leftHints objectAtIndex: i]];
|
||||
}
|
||||
|
||||
count = [bests count];
|
||||
|
||||
|
||||
if (count >= 1)
|
||||
{
|
||||
float start, end, position;
|
||||
position = [[bests objectAtIndex: 0] position];
|
||||
|
||||
start = NSMinY(frame);
|
||||
end = NSMaxY(frame);
|
||||
for ( i = 0; i < count; i++ )
|
||||
{
|
||||
start = MIN(NSMinY([[bests objectAtIndex: i] frame]), start);
|
||||
end = MAX(NSMaxY([[bests objectAtIndex: i] frame]), end);
|
||||
}
|
||||
|
||||
[[NSColor redColor] set];
|
||||
NSRectFill(NSMakeRect(position - 1, start, 2, end - start));
|
||||
gpi->lastLeftRect = NSMakeRect(position - 1, start, 2, end - start);
|
||||
leftOfFrame = position;
|
||||
}
|
||||
}
|
||||
|
||||
if (gpi->knob == IBTopRightKnobPosition
|
||||
|| gpi->knob == IBMiddleRightKnobPosition
|
||||
|| gpi->knob == IBBottomRightKnobPosition)
|
||||
{
|
||||
bests = [NSMutableArray arrayWithCapacity: 4];
|
||||
minimum = 10;
|
||||
count = [gpi->rightHints count];
|
||||
for ( i = 0; i < count; i++ )
|
||||
{
|
||||
lastDistance = [[gpi->rightHints objectAtIndex: i]
|
||||
distanceToFrame: frame];
|
||||
if (lastDistance < minimum)
|
||||
{
|
||||
bests = [NSMutableArray arrayWithCapacity: 4];
|
||||
[bests addObject: [gpi->rightHints objectAtIndex: i]];
|
||||
minimum = lastDistance;
|
||||
}
|
||||
else if (lastDistance == minimum)
|
||||
[bests addObject: [gpi->rightHints objectAtIndex: i]];
|
||||
}
|
||||
|
||||
count = [bests count];
|
||||
|
||||
|
||||
if (count >= 1)
|
||||
{
|
||||
float start, end, position;
|
||||
position = [[bests objectAtIndex: 0] position];
|
||||
|
||||
start = NSMinY(frame);
|
||||
end = NSMaxY(frame);
|
||||
for ( i = 0; i < count; i++ )
|
||||
{
|
||||
start = MIN(NSMinY([[bests objectAtIndex: i] frame]), start);
|
||||
end = MAX(NSMaxY([[bests objectAtIndex: i] frame]), end);
|
||||
}
|
||||
|
||||
[[NSColor redColor] set];
|
||||
NSRectFill(NSMakeRect(position - 1, start, 2, end - start));
|
||||
gpi->lastRightRect = NSMakeRect(position - 1, start, 2, end - start);
|
||||
rightOfFrame = position;
|
||||
}
|
||||
}
|
||||
|
||||
if (gpi->knob == IBTopRightKnobPosition
|
||||
|| gpi->knob == IBTopLeftKnobPosition
|
||||
|| gpi->knob == IBTopMiddleKnobPosition)
|
||||
{
|
||||
bests = [NSMutableArray arrayWithCapacity: 4];
|
||||
minimum = 10;
|
||||
count = [gpi->topHints count];
|
||||
for ( i = 0; i < count; i++ )
|
||||
{
|
||||
lastDistance = [[gpi->topHints objectAtIndex: i]
|
||||
distanceToFrame: frame];
|
||||
if (lastDistance < minimum)
|
||||
{
|
||||
bests = [NSMutableArray arrayWithCapacity: 4];
|
||||
[bests addObject: [gpi->topHints objectAtIndex: i]];
|
||||
minimum = lastDistance;
|
||||
}
|
||||
else if (lastDistance == minimum)
|
||||
[bests addObject: [gpi->topHints objectAtIndex: i]];
|
||||
}
|
||||
|
||||
count = [bests count];
|
||||
|
||||
|
||||
if (count >= 1)
|
||||
{
|
||||
float start, end, position;
|
||||
position = [[bests objectAtIndex: 0] position];
|
||||
|
||||
start = NSMinX(frame);
|
||||
end = NSMaxX(frame);
|
||||
for ( i = 0; i < count; i++ )
|
||||
{
|
||||
start = MIN(NSMinX([[bests objectAtIndex: i] frame]), start);
|
||||
end = MAX(NSMaxX([[bests objectAtIndex: i] frame]), end);
|
||||
}
|
||||
|
||||
[[NSColor redColor] set];
|
||||
NSRectFill(NSMakeRect(start, position - 1, end - start, 2));
|
||||
gpi->lastTopRect = NSMakeRect(start, position - 1, end - start, 2);
|
||||
topOfFrame = position;
|
||||
}
|
||||
}
|
||||
|
||||
if (gpi->knob == IBBottomRightKnobPosition
|
||||
|| gpi->knob == IBBottomLeftKnobPosition
|
||||
|| gpi->knob == IBBottomMiddleKnobPosition)
|
||||
{
|
||||
bests = [NSMutableArray arrayWithCapacity: 4];
|
||||
minimum = 10;
|
||||
count = [gpi->bottomHints count];
|
||||
for ( i = 0; i < count; i++ )
|
||||
{
|
||||
lastDistance = [[gpi->bottomHints objectAtIndex: i]
|
||||
distanceToFrame: frame];
|
||||
if (lastDistance < minimum)
|
||||
{
|
||||
bests = [NSMutableArray arrayWithCapacity: 4];
|
||||
[bests addObject: [gpi->bottomHints objectAtIndex: i]];
|
||||
minimum = lastDistance;
|
||||
}
|
||||
else if (lastDistance == minimum)
|
||||
[bests addObject: [gpi->bottomHints objectAtIndex: i]];
|
||||
}
|
||||
|
||||
count = [bests count];
|
||||
|
||||
|
||||
if (count >= 1)
|
||||
{
|
||||
float start, end, position;
|
||||
position = [[bests objectAtIndex: 0] position];
|
||||
|
||||
start = NSMinX(frame);
|
||||
end = NSMaxX(frame);
|
||||
for ( i = 0; i < count; i++ )
|
||||
{
|
||||
start = MIN(NSMinX([[bests objectAtIndex: i] frame]), start);
|
||||
end = MAX(NSMaxX([[bests objectAtIndex: i] frame]), end);
|
||||
}
|
||||
|
||||
[[NSColor redColor] set];
|
||||
NSRectFill(NSMakeRect(start, position - 1, end - start, 2));
|
||||
gpi->lastBottomRect = NSMakeRect(start, position - 1, end - start, 2);
|
||||
bottomOfFrame = position;
|
||||
}
|
||||
}
|
||||
|
||||
gpi->hintFrame = NSMakeRect (leftOfFrame, bottomOfFrame,
|
||||
rightOfFrame - leftOfFrame,
|
||||
topOfFrame - bottomOfFrame);
|
||||
|
||||
GormShowFrameWithKnob(gpi->hintFrame, gpi->knob);
|
||||
gpi->oldRect = GormExtBoundsForRect(gpi->hintFrame);
|
||||
gpi->oldRect.origin.x--;
|
||||
gpi->oldRect.origin.y--;
|
||||
gpi->oldRect.size.width += 2;
|
||||
gpi->oldRect.size.height += 2;
|
||||
|
||||
}
|
||||
|
||||
- (void) updateResizingWithFrame: (NSRect) frame
|
||||
andEvent: (NSEvent *)theEvent
|
||||
andPlacementInfo: (GormPlacementInfo*) gpi
|
||||
{
|
||||
if ([theEvent modifierFlags] & NSAlternateKeyMask)
|
||||
[self _altDisplayFrame: frame
|
||||
withPlacementInfo: gpi];
|
||||
else if ([theEvent modifierFlags] & NSShiftKeyMask)
|
||||
[self _displayFrame: frame
|
||||
withPlacementInfo: gpi];
|
||||
else
|
||||
[self _displayFrameWithHint: frame
|
||||
withPlacementInfo: gpi];
|
||||
}
|
||||
|
||||
- (void) validateFrame: (NSRect) frame
|
||||
withEvent: (NSEvent *) theEvent
|
||||
andPlacementInfo: (GormPlacementInfo*)gpi
|
||||
{
|
||||
frame = gpi->lastFrame;
|
||||
if ([theEvent modifierFlags] & NSAlternateKeyMask)
|
||||
{
|
||||
NSSize cellSize = [self frame].size;
|
||||
id editor;
|
||||
int col;
|
||||
int row;
|
||||
NSMatrix *matrix;
|
||||
|
||||
col = gpi->lastFrame.size.width / cellSize.width;
|
||||
row = gpi->lastFrame.size.height / cellSize.height;
|
||||
|
||||
// NSLog(@"parentEditor %@", we);
|
||||
|
||||
// let's morph into a matrix
|
||||
matrix = [[NSMatrix alloc] initWithFrame: gpi->lastFrame
|
||||
mode: NSRadioModeMatrix
|
||||
prototype: [_EO cell]
|
||||
numberOfRows: row
|
||||
numberOfColumns: col];
|
||||
|
||||
[matrix setIntercellSpacing: NSMakeSize(0, 0)];
|
||||
[matrix setFrame: gpi->lastFrame];
|
||||
|
||||
|
||||
RETAIN(self);
|
||||
|
||||
[[self superview] addSubview: matrix];
|
||||
|
||||
[parent selectObjects: [NSArray arrayWithObject: self]];
|
||||
[parent deleteSelection];
|
||||
|
||||
[document attachObject: matrix toParent: _EO];
|
||||
|
||||
// NSLog(@"gonna open editor");
|
||||
editor = [document editorForObject: matrix
|
||||
inEditor: parent
|
||||
create: YES];
|
||||
|
||||
// NSLog(@"editor %@", editor);
|
||||
|
||||
[parent selectObjects: [NSArray arrayWithObject: editor]];
|
||||
|
||||
|
||||
RELEASE(self);
|
||||
}
|
||||
else if ([theEvent modifierFlags] & NSShiftKeyMask)
|
||||
{
|
||||
[self setFrame: frame];
|
||||
}
|
||||
else
|
||||
{
|
||||
[super validateFrame: frame
|
||||
withEvent: theEvent
|
||||
andPlacementInfo: gpi];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSTextField (GormObjectAdditions)
|
||||
- (NSString*) editorClassName
|
||||
{
|
||||
return @"GormTextFieldEditor";
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
|
||||
@interface GormTextFieldEditor : GormControlEditor
|
||||
|
||||
@end
|
||||
|
||||
@implementation GormTextFieldEditor
|
||||
- (void) mouseDown: (NSEvent*)theEvent
|
||||
{
|
||||
if (([theEvent clickCount] == 2) && [parent isOpened])
|
||||
// double-clicked -> let's edit
|
||||
{
|
||||
[self editTextField: _editedObject
|
||||
withEvent: theEvent];
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName: IBSelectionChangedNotification
|
||||
object: parent];
|
||||
}
|
||||
else
|
||||
{
|
||||
[super mouseDown: theEvent];
|
||||
}
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
|
|
@ -19,8 +19,8 @@
|
|||
self = [super init];
|
||||
if (self != nil)
|
||||
{
|
||||
NSDictionary *table = nil;
|
||||
NSBundle *bundle = nil;
|
||||
// NSDictionary *table = nil;
|
||||
// NSBundle *bundle = nil;
|
||||
_classManager = nil;
|
||||
_currentSelection = nil;
|
||||
_currentSelectionClassName = nil;
|
||||
|
|
|
@ -86,7 +86,6 @@
|
|||
if (version == 1)
|
||||
{
|
||||
NSString *string;
|
||||
unsigned int mask;
|
||||
// do not decode super. We need to maintain mapping to NibItems
|
||||
string = [aCoder decodeObject];
|
||||
_frame = [aCoder decodeRect];
|
||||
|
|
|
@ -147,6 +147,7 @@ static NSImage *classesImage = nil;
|
|||
return [NSArray arrayWithArray: connections];
|
||||
}
|
||||
|
||||
|
||||
- (void) attachObject: (id)anObject toParent: (id)aParent
|
||||
{
|
||||
NSArray *old;
|
||||
|
@ -574,7 +575,7 @@ static NSImage *classesImage = nil;
|
|||
NSString *actionToken = nil;
|
||||
|
||||
classfound = [headerScanner scanUpToString: @"@interface"
|
||||
intoString: nil];
|
||||
intoString: NULL];
|
||||
|
||||
[headerScanner scanUpToString: @"@end"
|
||||
intoString: &classString];
|
||||
|
@ -596,15 +597,15 @@ static NSImage *classesImage = nil;
|
|||
*outlets = [NSMutableArray array];
|
||||
|
||||
[classScanner scanString: @"@interface"
|
||||
intoString: nil];
|
||||
intoString: NULL];
|
||||
[classScanner scanUpToCharactersFromSet: stopSet
|
||||
intoString: &className];
|
||||
[classScanner scanString: @":"
|
||||
intoString: nil];
|
||||
intoString: NULL];
|
||||
[classScanner scanUpToString: @"\n"
|
||||
intoString: &superClassName];
|
||||
[classScanner scanUpToString: @"{"
|
||||
intoString: nil];
|
||||
intoString: NULL];
|
||||
[classScanner scanUpToString: @"}"
|
||||
intoString: &ivarString];
|
||||
[classScanner scanUpToString: @"@end"
|
||||
|
@ -624,9 +625,9 @@ static NSImage *classesImage = nil;
|
|||
NSString *outlet = nil;
|
||||
|
||||
[ivarScanner scanUpToString: outletToken
|
||||
intoString: nil];
|
||||
intoString: NULL];
|
||||
[ivarScanner scanString: outletToken
|
||||
intoString: nil];
|
||||
intoString: NULL];
|
||||
[ivarScanner scanUpToString: @";"
|
||||
intoString: &outlet];
|
||||
if(![ivarScanner isAtEnd])
|
||||
|
@ -649,15 +650,15 @@ static NSImage *classesImage = nil;
|
|||
|
||||
// Scan the method name
|
||||
[methodScanner scanUpToString: actionToken
|
||||
intoString: nil];
|
||||
intoString: NULL];
|
||||
[methodScanner scanString: actionToken
|
||||
intoString: nil];
|
||||
intoString: NULL];
|
||||
[methodScanner scanUpToCharactersFromSet: stopSet
|
||||
intoString: &action];
|
||||
|
||||
// This will return true if the method has args.
|
||||
hasArguments = [methodScanner scanString: @":"
|
||||
intoString: nil];
|
||||
intoString: NULL];
|
||||
|
||||
if(hasArguments)
|
||||
{
|
||||
|
@ -875,7 +876,10 @@ static NSImage *classesImage = nil;
|
|||
links = [self connectorsForSource: anObject
|
||||
ofClass: [GormObjectToEditor class]];
|
||||
NSAssert([links count] < 2, NSInternalInconsistencyException);
|
||||
[connections removeObjectIdenticalTo: [links objectAtIndex: 0]];
|
||||
if ([links count] == 1)
|
||||
{
|
||||
[connections removeObjectIdenticalTo: [links objectAtIndex: 0]];
|
||||
}
|
||||
|
||||
/*
|
||||
* Make sure that this editor is not the selection owner.
|
||||
|
@ -937,11 +941,21 @@ static NSImage *classesImage = nil;
|
|||
[connections addObject: link];
|
||||
RELEASE(link);
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"WARNING anEditor = editor");
|
||||
}
|
||||
[editor activate];
|
||||
RELEASE(editor);
|
||||
return editor;
|
||||
}
|
||||
else if ([links count] == 0)
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
else
|
||||
{
|
||||
[[[links lastObject] destination] activate];
|
||||
return [[links lastObject] destination];
|
||||
}
|
||||
}
|
||||
|
@ -1591,7 +1605,7 @@ static NSImage *classesImage = nil;
|
|||
- (id<IBEditors>) openEditorForObject: (id)anObject
|
||||
{
|
||||
id<IBEditors> e = [self editorForObject: anObject create: YES];
|
||||
id<IBEditors> p = [self parentEditorForEditor: e];
|
||||
id<IBEditors, IBSelectionOwners> p = [self parentEditorForEditor: e];
|
||||
|
||||
if (p != nil && p != objectsView)
|
||||
{
|
||||
|
@ -1602,13 +1616,13 @@ static NSImage *classesImage = nil;
|
|||
return e;
|
||||
}
|
||||
|
||||
- (id<IBEditors>) parentEditorForEditor: (id<IBEditors>)anEditor
|
||||
- (id<IBEditors, IBSelectionOwners>) parentEditorForEditor: (id<IBEditors>)anEditor
|
||||
{
|
||||
NSArray *links;
|
||||
GormObjectToEditor *con;
|
||||
|
||||
links = [self connectorsForSource: anEditor
|
||||
ofClass: [GormObjectToEditor class]];
|
||||
ofClass: [GormEditorToParent class]];
|
||||
con = [links lastObject];
|
||||
return [con destination];
|
||||
}
|
||||
|
@ -2100,7 +2114,8 @@ static NSImage *classesImage = nil;
|
|||
- (void) setSelectionFromEditor: (id<IBEditors>)anEditor
|
||||
{
|
||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
NSLog(@"setSelectionFromEditor %@", anEditor);
|
||||
NSDebugLog(@"setSelectionFromEditor %@", anEditor);
|
||||
[[anEditor window] makeFirstResponder: anEditor];
|
||||
[nc postNotificationName: IBSelectionChangedNotification
|
||||
object: anEditor];
|
||||
}
|
||||
|
@ -2144,10 +2159,27 @@ static NSImage *classesImage = nil;
|
|||
else if ([object isKindOfClass: [NSView class]] == YES)
|
||||
{
|
||||
/*
|
||||
* Nowmal view objects just get link markup drawn on them.
|
||||
* Normal view objects just get link markup drawn on them.
|
||||
*/
|
||||
*r = [object convertRect: [object bounds] toView: nil];
|
||||
return [object window];
|
||||
id temp = object;
|
||||
id editor = [self editorForObject: temp create: NO];
|
||||
|
||||
while((temp != nil) && (editor == nil))
|
||||
{
|
||||
temp = [temp superview];
|
||||
editor = [self editorForObject: temp create: NO];
|
||||
}
|
||||
|
||||
if (temp == nil)
|
||||
{
|
||||
*r = [object convertRect: [object bounds] toView: nil];
|
||||
}
|
||||
else if ([editor respondsToSelector:
|
||||
@selector(windowAndRect:forObject:)])
|
||||
{
|
||||
NSLog(@"temp != nil");
|
||||
return [editor windowAndRect: r forObject: object];
|
||||
}
|
||||
}
|
||||
else if ([object isKindOfClass: [NSTableColumn class]] == YES)
|
||||
{
|
||||
|
@ -2183,6 +2215,9 @@ static NSImage *classesImage = nil;
|
|||
*r = NSZeroRect;
|
||||
return nil;
|
||||
}
|
||||
|
||||
// never reached, keeps gcc happy
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSWindow*) window
|
||||
|
@ -2488,5 +2523,23 @@ shouldEditTableColumn: (NSTableColumn *)tableColumn
|
|||
return result;
|
||||
}
|
||||
|
||||
// for debuging purpose
|
||||
- (void) printAllEditors
|
||||
{
|
||||
NSMutableSet *set = [NSMutableSet setWithCapacity: 16];
|
||||
NSEnumerator *enumerator = [connections objectEnumerator];
|
||||
id<IBConnectors> c;
|
||||
|
||||
while ((c = [enumerator nextObject]) != nil)
|
||||
{
|
||||
if ([GormObjectToEditor class] == [c class])
|
||||
{
|
||||
[set addObject: [c destination]];
|
||||
}
|
||||
}
|
||||
|
||||
NSLog(@"all editors %@", set);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
|
31
GormInternalViewEditor.h
Normal file
31
GormInternalViewEditor.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
/* GormInternalViewEditor.h
|
||||
*
|
||||
* Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
*
|
||||
* Author: Pierre-Yves Rivaille <pyrivail@ens-lyon.fr>
|
||||
* Date: 2002
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#import "GormViewWithContentViewEditor.h"
|
||||
|
||||
@interface GormInternalViewEditor: GormViewWithContentViewEditor
|
||||
{
|
||||
}
|
||||
- (NSArray*) destroyAndListSubviews;
|
||||
@end
|
865
GormInternalViewEditor.m
Normal file
865
GormInternalViewEditor.m
Normal file
|
@ -0,0 +1,865 @@
|
|||
/* GormInternalViewEditor.m
|
||||
*
|
||||
* Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
*
|
||||
* Author: Pierre-Yves Rivaille <pyrivail@ens-lyon.fr>
|
||||
* Date: 2002
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#import <AppKit/AppKit.h>
|
||||
|
||||
#import "GormPrivate.h"
|
||||
|
||||
#import "GormInternalViewEditor.h"
|
||||
|
||||
@class GormEditorToParent;
|
||||
@class GSWindowView;
|
||||
|
||||
@implementation NSView (GormObjectAdditions)
|
||||
- (NSString*) editorClassName
|
||||
{
|
||||
if ([self superview] &&
|
||||
(([[self superview] respondsToSelector: @selector(contentView)] &&
|
||||
[(id)[self superview] contentView] == self)
|
||||
||
|
||||
[[self superview] isKindOfClass: [NSTabView class]]
|
||||
||
|
||||
[[self superview] isKindOfClass: [GSWindowView class]]
|
||||
))
|
||||
{
|
||||
return @"GormInternalViewEditor";
|
||||
}
|
||||
else
|
||||
{
|
||||
return @"GormViewEditor";
|
||||
}
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
@implementation GormInternalViewEditor
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
RELEASE(selection);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
||||
- (BOOL) activate
|
||||
{
|
||||
if (activated == NO)
|
||||
{
|
||||
NSEnumerator *enumerator;
|
||||
NSView *sub;
|
||||
NSView *superview = [_editedObject superview];
|
||||
|
||||
// NSLog(@"ac %@ %@ %@", self, _editedObject, superview);
|
||||
|
||||
|
||||
[self setFrame: [_editedObject frame]];
|
||||
[self setBounds: [self frame]];
|
||||
|
||||
if ([superview isKindOfClass: [NSBox class]])
|
||||
{
|
||||
NSBox *boxSuperview = (NSBox *) superview;
|
||||
[boxSuperview setContentView: self];
|
||||
}
|
||||
else if ([superview isKindOfClass: [NSTabView class]])
|
||||
{
|
||||
NSTabView *tabSuperview = (NSTabView *) superview;
|
||||
[tabSuperview removeSubview:
|
||||
[[tabSuperview selectedTabViewItem] view]];
|
||||
[[tabSuperview selectedTabViewItem] setView: self];
|
||||
[tabSuperview addSubview: self];
|
||||
[self setFrame: [tabSuperview contentRect]];
|
||||
[self setAutoresizingMask:
|
||||
NSViewWidthSizable | NSViewHeightSizable];
|
||||
// NSLog(@"ac %d %d %d",
|
||||
// [tabSuperview autoresizesSubviews],
|
||||
// [self autoresizesSubviews],
|
||||
// [_editedObject autoresizesSubviews]);
|
||||
}
|
||||
else if ([superview isKindOfClass: [GSWindowView class]])
|
||||
{
|
||||
[[superview window] setContentView: self];
|
||||
}
|
||||
|
||||
[self addSubview: _editedObject];
|
||||
|
||||
[_editedObject setPostsFrameChangedNotifications: YES];
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver: self
|
||||
selector: @selector(editedObjectFrameDidChange:)
|
||||
name: NSViewFrameDidChangeNotification
|
||||
object: _editedObject];
|
||||
|
||||
[self setPostsFrameChangedNotifications: YES];
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver: self
|
||||
selector: @selector(frameDidChange:)
|
||||
name: NSViewFrameDidChangeNotification
|
||||
object: self];
|
||||
|
||||
parent = [document parentEditorForEditor: self];
|
||||
|
||||
if ([parent isKindOfClass: [GormViewEditor class]])
|
||||
[parent setNeedsDisplay: YES];
|
||||
else
|
||||
[self setNeedsDisplay: YES];
|
||||
activated = YES;
|
||||
|
||||
|
||||
|
||||
enumerator = [[NSArray arrayWithArray: [_editedObject subviews]]
|
||||
objectEnumerator];
|
||||
|
||||
while ((sub = [enumerator nextObject]) != nil)
|
||||
{
|
||||
// NSLog(@"ac %@ editorForObject: %@", self, sub);
|
||||
if ([sub isKindOfClass: [GormViewEditor class]] == NO)
|
||||
{
|
||||
// NSLog(@"ac %@ yes", self);
|
||||
[document editorForObject: sub
|
||||
inEditor: self
|
||||
create: YES];
|
||||
}
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
||||
// - (void) close
|
||||
// {
|
||||
// NSEnumerator *enumerator;
|
||||
// GormViewEditor *sub;
|
||||
|
||||
// enumerator = [[NSArray arrayWithArray: [_editedObject subviews]]
|
||||
// objectEnumerator];
|
||||
|
||||
// while ((sub = [enumerator nextObject]) != nil)
|
||||
// {
|
||||
// if ([sub respondsToSelector: @selector(deactivate)] == NO)
|
||||
// {
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// NSLog(@"deactivating, deac %@", sub);
|
||||
// [sub deactivate];
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
- (void) deactivate
|
||||
{
|
||||
if (activated == YES)
|
||||
{
|
||||
NSView *superview = [self superview];
|
||||
|
||||
[self deactivateSubeditors];
|
||||
|
||||
if ([superview isKindOfClass: [NSBox class]])
|
||||
{
|
||||
NSBox *boxSuperview = (NSBox *) superview;
|
||||
[self removeSubview: _editedObject];
|
||||
[boxSuperview setContentView: _editedObject];
|
||||
}
|
||||
else if ([superview isKindOfClass: [NSTabView class]])
|
||||
{
|
||||
// NSLog(@"deactivating %@", self);
|
||||
NSTabView *tabSuperview = (NSTabView *) superview;
|
||||
[tabSuperview removeSubview: self];
|
||||
[[tabSuperview selectedTabViewItem]
|
||||
setView: _editedObject];
|
||||
[tabSuperview addSubview:
|
||||
[[tabSuperview selectedTabViewItem] view]];
|
||||
[[[tabSuperview selectedTabViewItem] view]
|
||||
setFrame: [tabSuperview contentRect]];
|
||||
}
|
||||
else if ([superview isKindOfClass: [GSWindowView class]])
|
||||
{
|
||||
[self removeSubview: _editedObject];
|
||||
[[superview window] setContentView: _editedObject];
|
||||
}
|
||||
[[NSNotificationCenter defaultCenter] removeObserver: self];
|
||||
|
||||
}
|
||||
|
||||
activated = NO;
|
||||
}
|
||||
|
||||
- (id) initWithObject: (id)anObject
|
||||
inDocument: (id<IBDocuments>)aDocument
|
||||
{
|
||||
opened = NO;
|
||||
openedSubeditor = nil;
|
||||
|
||||
if ((self = [super initWithObject: anObject
|
||||
inDocument: aDocument]) == nil)
|
||||
return nil;
|
||||
|
||||
selection = [[NSMutableArray alloc] initWithCapacity: 5];
|
||||
|
||||
|
||||
|
||||
[self registerForDraggedTypes: [NSArray arrayWithObjects:
|
||||
IBViewPboardType, GormLinkPboardType, IBFormatterPboardType, nil]];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
// - (void) reactivateWithObject: (id) anObject
|
||||
// inDocument: (id<IBDocuments>)aDocument
|
||||
// {
|
||||
// [super reactivateWithObject: anObject
|
||||
// inDocument: aDocument];
|
||||
|
||||
// }
|
||||
|
||||
|
||||
- (void) makeSelectionVisible: (BOOL) value
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
- (NSArray*) selection
|
||||
{
|
||||
int i;
|
||||
int count = [selection count];
|
||||
NSMutableArray *result = [NSMutableArray arrayWithCapacity: count];
|
||||
|
||||
if (count != 0)
|
||||
{
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
[result addObject: [[selection objectAtIndex: i] editedObject]];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return [parent selection];
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
- (void) deleteSelection
|
||||
{
|
||||
int i;
|
||||
int count = [selection count];
|
||||
id temp;
|
||||
|
||||
for (i = count - 1; i >= 0; i--)
|
||||
{
|
||||
temp = [[selection objectAtIndex: i] editedObject];
|
||||
|
||||
[[selection objectAtIndex: i] detachSubviews];
|
||||
[document detachObject: temp];
|
||||
[[selection objectAtIndex: i] close];
|
||||
|
||||
[temp removeFromSuperview];
|
||||
[selection removeObjectAtIndex: i];
|
||||
}
|
||||
|
||||
[self selectObjects: [NSArray array]];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
- (void) mouseDown: (NSEvent *) theEvent
|
||||
{
|
||||
BOOL onKnob = NO;
|
||||
|
||||
{
|
||||
if ([parent respondsToSelector: @selector(selection)] &&
|
||||
[[parent selection] containsObject: _editedObject])
|
||||
{
|
||||
IBKnobPosition knob = IBNoneKnobPosition;
|
||||
NSPoint mouseDownPoint =
|
||||
[self convertPoint: [theEvent locationInWindow]
|
||||
fromView: nil];
|
||||
knob = GormKnobHitInRect([self bounds],
|
||||
mouseDownPoint);
|
||||
if (knob != IBNoneKnobPosition)
|
||||
onKnob = YES;
|
||||
}
|
||||
if (onKnob == YES)
|
||||
{
|
||||
if (parent)
|
||||
return [parent mouseDown: theEvent];
|
||||
else
|
||||
return [self noResponderFor: @selector(mouseDown:)];
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
if ([parent isOpened] == NO)
|
||||
{
|
||||
NSDebugLog(@"md %@ calling my parent %@", self, parent);
|
||||
[super mouseDown: theEvent];
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// are we on the knob of a selected view ?
|
||||
{
|
||||
int count = [selection count];
|
||||
int i;
|
||||
GormViewEditor *knobView = nil;
|
||||
IBKnobPosition knob = IBNoneKnobPosition;
|
||||
NSPoint mouseDownPoint;
|
||||
|
||||
for ( i = 0; i < count; i++ )
|
||||
{
|
||||
mouseDownPoint = [[[selection objectAtIndex: i] superview]
|
||||
convertPoint: [theEvent locationInWindow]
|
||||
fromView: nil];
|
||||
|
||||
knob = GormKnobHitInRect([[selection objectAtIndex: i] frame],
|
||||
mouseDownPoint);
|
||||
|
||||
if (knob != IBNoneKnobPosition)
|
||||
{
|
||||
knobView = [selection objectAtIndex: i];
|
||||
[self selectObjects: [NSMutableArray arrayWithObject: knobView]];
|
||||
// we should set knobView as the only view selected
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( openedSubeditor != nil )
|
||||
{
|
||||
mouseDownPoint = [[openedSubeditor superview]
|
||||
convertPoint: [theEvent locationInWindow]
|
||||
fromView: nil];
|
||||
|
||||
knob = GormKnobHitInRect([openedSubeditor frame],
|
||||
mouseDownPoint);
|
||||
if (knob != IBNoneKnobPosition)
|
||||
{
|
||||
knobView = openedSubeditor;
|
||||
// we should take back the selection
|
||||
// we should select openedSubeditor only
|
||||
[self selectObjects: [NSMutableArray arrayWithObject: knobView]];
|
||||
[[self window] disableFlushWindow];
|
||||
[self display];
|
||||
[[self window] enableFlushWindow];
|
||||
[[self window] flushWindow];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (knobView != nil)
|
||||
{
|
||||
[self handleMouseOnKnob: knob
|
||||
ofView: knobView
|
||||
withEvent: theEvent];
|
||||
// NSLog(@"resize %@", knobView);
|
||||
[self setNeedsDisplay: YES];
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
GormViewEditor *editorView;
|
||||
|
||||
// get the view we are on
|
||||
{
|
||||
NSPoint mouseDownPoint;
|
||||
NSView *result;
|
||||
GormViewEditor *theParent;
|
||||
|
||||
mouseDownPoint = [self
|
||||
convertPoint: [theEvent locationInWindow]
|
||||
fromView: nil];
|
||||
|
||||
result = [_editedObject hitTest: mouseDownPoint];
|
||||
|
||||
// NSDebugLog(@"md %@ result %@", self, result);
|
||||
// NSLog(@"_editedObject %@", _editedObject);
|
||||
|
||||
// we should get a result which is a direct subeditor
|
||||
{
|
||||
id temp = result;
|
||||
// int i = 0;
|
||||
|
||||
// NSLog(@"md %@ parent %@", self, parent);
|
||||
if ([temp isKindOfClass: [GormViewEditor class]])
|
||||
theParent = [(GormViewEditor *)temp parent];
|
||||
while ((temp != nil) && (theParent != self) && (temp != self))
|
||||
{
|
||||
// NSLog(@"md %@ temp = %@", self, temp);
|
||||
temp = [temp superview];
|
||||
while (![temp isKindOfClass: [GormViewEditor class]])
|
||||
{
|
||||
// if (i++ > 100)
|
||||
// sleep(3);
|
||||
// NSLog(@"md %@ temp = %@", self, temp);
|
||||
temp = [temp superview];
|
||||
}
|
||||
theParent = [(GormViewEditor *)temp parent];
|
||||
// NSLog(@"temp (%@) 's parent is %@", temp, theParent);
|
||||
}
|
||||
// NSLog(@"md %@ temp = %@", self, temp);
|
||||
if (temp != nil)
|
||||
{
|
||||
result = temp;
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"WARNING -- strange case");
|
||||
result = self;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ([result isKindOfClass: [GormViewEditor class]])
|
||||
{
|
||||
/*
|
||||
if (result != self)
|
||||
{
|
||||
[self selectObjects: [NSMutableArray arrayWithObject: result]];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self selectObjects: [NSMutableArray array]];
|
||||
}
|
||||
[[self window] disableFlushWindow];
|
||||
[self display];
|
||||
[[self window] enableFlushWindow];
|
||||
[[self window] flushWindow];
|
||||
NSLog(@"clicked on %@", result);
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
// NSLog(@"md %@ result = nil", self);
|
||||
result = nil;
|
||||
}
|
||||
|
||||
editorView = (GormViewEditor *)result;
|
||||
}
|
||||
|
||||
if (([theEvent clickCount] == 2)
|
||||
&& [editorView isKindOfClass: [GormViewWithSubviewsEditor class]]
|
||||
&& ([(id)editorView canBeOpened] == YES)
|
||||
&& (editorView != self))
|
||||
|
||||
{
|
||||
[(GormViewWithSubviewsEditor *) editorView setOpened: YES];
|
||||
[self silentlyResetSelection];
|
||||
openedSubeditor = (GormViewWithSubviewsEditor *) editorView;
|
||||
[self setNeedsDisplay: YES];
|
||||
// NSLog(@"md %@ editor should open", self);
|
||||
return;
|
||||
}
|
||||
|
||||
if (editorView != self)
|
||||
{
|
||||
[self handleMouseOnView: editorView
|
||||
withEvent: theEvent];
|
||||
}
|
||||
else // editorView == self
|
||||
{
|
||||
// NSLog(@"editorView == self");
|
||||
[self selectObjects: [NSMutableArray array]];
|
||||
[self setNeedsDisplay: YES];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
// are we on a selected view ?
|
||||
{
|
||||
int count = [selection count];
|
||||
int i;
|
||||
BOOL inView = NO;
|
||||
NSPoint mouseDownPoint;
|
||||
|
||||
|
||||
for ( i = 0; i < count; i++ )
|
||||
{
|
||||
mouseDownPoint = [[[selection objectAtIndex: i] superview]
|
||||
convertPoint: [theEvent locationInWindow]
|
||||
fromView: nil];
|
||||
|
||||
if ([[[selection objectAtIndex: i] superview]
|
||||
mouse: mouseDownPoint
|
||||
inRect: [[selection objectAtIndex: i] frame]])
|
||||
{
|
||||
inView = YES;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (inView)
|
||||
{
|
||||
NSLog(@"inside %@", [selection objectAtIndex: i]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
*/
|
||||
// are we on a view ?
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
- (unsigned) draggingEntered: (id<NSDraggingInfo>)sender
|
||||
{
|
||||
NSRect rect = [_editedObject bounds];
|
||||
NSPoint loc = [sender draggingLocation];
|
||||
loc = [_editedObject convertPoint: loc fromView: nil];
|
||||
|
||||
if (NSMouseInRect(loc, [_editedObject bounds], NO) == NO)
|
||||
{
|
||||
return NSDragOperationNone;
|
||||
}
|
||||
else
|
||||
{
|
||||
rect.origin.x += 3;
|
||||
rect.origin.y += 2;
|
||||
rect.size.width -= 5;
|
||||
rect.size.height -= 5;
|
||||
|
||||
[_editedObject lockFocus];
|
||||
|
||||
[[NSColor darkGrayColor] set];
|
||||
NSFrameRectWithWidth(rect, 2);
|
||||
|
||||
[_editedObject unlockFocus];
|
||||
[[self window] flushWindow];
|
||||
return NSDragOperationCopy;
|
||||
}
|
||||
}
|
||||
|
||||
- (void) draggingExited: (id<NSDraggingInfo>)sender
|
||||
{
|
||||
NSRect rect = [_editedObject bounds];
|
||||
rect.origin.x += 3;
|
||||
rect.origin.y += 2;
|
||||
rect.size.width -= 5;
|
||||
rect.size.height -= 5;
|
||||
|
||||
rect.origin.x --;
|
||||
rect.size.width ++;
|
||||
rect.size.height ++;
|
||||
|
||||
[[self window] disableFlushWindow];
|
||||
[self displayRect:
|
||||
[_editedObject convertRect: rect
|
||||
toView: self]];
|
||||
[[self window] enableFlushWindow];
|
||||
[[self window] flushWindow];
|
||||
}
|
||||
|
||||
- (unsigned int) draggingUpdated: (id<NSDraggingInfo>)sender
|
||||
{
|
||||
NSPoint loc = [sender draggingLocation];
|
||||
NSRect rect = [_editedObject bounds];
|
||||
loc = [_editedObject
|
||||
convertPoint: loc fromView: nil];
|
||||
|
||||
rect.origin.x += 3;
|
||||
rect.origin.y += 2;
|
||||
rect.size.width -= 5;
|
||||
rect.size.height -= 5;
|
||||
|
||||
if (NSMouseInRect(loc, [_editedObject bounds], NO) == NO)
|
||||
{
|
||||
[[self window] disableFlushWindow];
|
||||
rect.origin.x --;
|
||||
rect.size.width ++;
|
||||
rect.size.height ++;
|
||||
[self displayRect:
|
||||
[_editedObject convertRect: rect
|
||||
toView: self]];
|
||||
[[self window] enableFlushWindow];
|
||||
[[self window] flushWindow];
|
||||
return NSDragOperationNone;
|
||||
}
|
||||
else
|
||||
{
|
||||
[_editedObject lockFocus];
|
||||
|
||||
[[NSColor darkGrayColor] set];
|
||||
NSFrameRectWithWidth(rect, 2);
|
||||
|
||||
[_editedObject unlockFocus];
|
||||
[[self window] flushWindow];
|
||||
return NSDragOperationCopy;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (BOOL) prepareForDragOperation: (id<NSDraggingInfo>)sender
|
||||
{
|
||||
NSString *dragType;
|
||||
NSArray *types;
|
||||
NSPasteboard *dragPb;
|
||||
|
||||
// NSLog(@"prepareForDragOperation called");
|
||||
|
||||
dragPb = [sender draggingPasteboard];
|
||||
|
||||
types = [dragPb types];
|
||||
|
||||
if ([types containsObject: IBViewPboardType] == YES)
|
||||
{
|
||||
dragType = IBViewPboardType;
|
||||
}
|
||||
else if ([types containsObject: GormLinkPboardType] == YES)
|
||||
{
|
||||
dragType = GormLinkPboardType;
|
||||
}
|
||||
else if ([types containsObject: IBFormatterPboardType] == YES)
|
||||
{
|
||||
dragType = IBFormatterPboardType;
|
||||
}
|
||||
else
|
||||
{
|
||||
dragType = nil;
|
||||
}
|
||||
|
||||
if (dragType == IBViewPboardType)
|
||||
{
|
||||
/*
|
||||
* We can accept views dropped anywhere.
|
||||
*/
|
||||
NSPoint loc = [sender draggingLocation];
|
||||
loc = [_editedObject
|
||||
convertPoint: loc fromView: nil];
|
||||
if (NSMouseInRect(loc, [_editedObject bounds], NO) == NO)
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL) performDragOperation: (id<NSDraggingInfo>)sender
|
||||
{
|
||||
NSString *dragType;
|
||||
NSPasteboard *dragPb;
|
||||
NSArray *types;
|
||||
|
||||
dragPb = [sender draggingPasteboard];
|
||||
|
||||
types = [dragPb types];
|
||||
|
||||
if ([types containsObject: IBViewPboardType] == YES)
|
||||
{
|
||||
dragType = IBViewPboardType;
|
||||
}
|
||||
else if ([types containsObject: GormLinkPboardType] == YES)
|
||||
{
|
||||
dragType = GormLinkPboardType;
|
||||
}
|
||||
else if ([types containsObject: IBFormatterPboardType] == YES)
|
||||
{
|
||||
dragType = IBFormatterPboardType;
|
||||
}
|
||||
else
|
||||
{
|
||||
dragType = nil;
|
||||
}
|
||||
|
||||
if (dragType == IBViewPboardType)
|
||||
{
|
||||
NSPoint loc = [sender draggingLocation];
|
||||
NSArray *views;
|
||||
NSEnumerator *enumerator;
|
||||
NSView *sub;
|
||||
|
||||
/*
|
||||
if (opened != YES)
|
||||
{
|
||||
NSLog(@"make ourself the editor");
|
||||
}
|
||||
else if (openedSubeditor != nil)
|
||||
{
|
||||
NSLog(@"close our subeditors");
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
* Ask the document to get the dragged views from the pasteboard and add
|
||||
* them to it's collection of known objects.
|
||||
*/
|
||||
views = [document pasteType: IBViewPboardType
|
||||
fromPasteboard: dragPb
|
||||
parent: _editedObject];
|
||||
/*
|
||||
* Now make all the views subviews of ourself, setting their origin to
|
||||
* be the point at which they were dropped (converted from window
|
||||
* coordinates to our own coordinates).
|
||||
*/
|
||||
loc = [_editedObject convertPoint: loc fromView: nil];
|
||||
if (NSMouseInRect(loc, [_editedObject bounds], NO) == NO)
|
||||
{
|
||||
// Dropped outside our view frame
|
||||
NSLog(@"Dropped outside current edit view");
|
||||
dragType = nil;
|
||||
return NO;
|
||||
}
|
||||
enumerator = [views objectEnumerator];
|
||||
while ((sub = [enumerator nextObject]) != nil)
|
||||
{
|
||||
NSRect rect = [sub frame];
|
||||
|
||||
rect.origin = [_editedObject
|
||||
convertPoint: [sender draggedImageLocation]
|
||||
fromView: nil];
|
||||
rect.origin.x = (int) rect.origin.x;
|
||||
rect.origin.y = (int) rect.origin.y;
|
||||
rect.size.width = (int) rect.size.width;
|
||||
rect.size.height = (int) rect.size.height;
|
||||
[sub setFrame: rect];
|
||||
|
||||
[_editedObject addSubview: sub];
|
||||
|
||||
{
|
||||
id editor;
|
||||
// NSLog(@"sub %@ %@", sub, [sub editorClassName]);
|
||||
editor = [document editorForObject: sub
|
||||
inEditor: self
|
||||
create: YES];
|
||||
// NSLog(@"editor %@", editor);
|
||||
[self selectObjects:
|
||||
[NSArray arrayWithObject: editor]];
|
||||
}
|
||||
}
|
||||
// FIXME we should maybe open ourself
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
- (void) pasteInSelection
|
||||
{
|
||||
[self pasteInView: _editedObject];
|
||||
}
|
||||
|
||||
@class GormBoxEditor;
|
||||
|
||||
// - (void) ungroupSelf
|
||||
// {
|
||||
// if ([parent isKindOfClass: [GormBoxEditor class]]
|
||||
// && [[parent parent] isKindOfClass:
|
||||
// [GormViewWithContentViewEditor class]])
|
||||
// {
|
||||
// NSEnumerator *enumerator;
|
||||
// GormViewEditor *subview;
|
||||
// enumerator = [[_editedObject subviews] objectEnumerator];
|
||||
// NSMutableArray *newSelection = [NSMutableArray array];
|
||||
|
||||
// [[parent parent] makeSubeditorResign];
|
||||
|
||||
// while ((subview = [enumerator nextObject]) != nil)
|
||||
// {
|
||||
// id v;
|
||||
// NSRect frame;
|
||||
// v = [subview editedObject];
|
||||
// frame = [v frame];
|
||||
// frame = [[parent parent] convertRect: frame
|
||||
// fromView: _editedObject];
|
||||
// [subview deactivate];
|
||||
|
||||
// [[[parent parent] editedObject] addSubview: v];
|
||||
// [v setFrame: frame];
|
||||
// [subview close];
|
||||
// [newSelection addObject:
|
||||
// [document editorForObject: v
|
||||
// inEditor: [parent parent]
|
||||
// create: YES]];
|
||||
// }
|
||||
// [[parent parent] selectObjects: newSelection];
|
||||
|
||||
// {
|
||||
// id thisBox = [parent editedObject];
|
||||
// [parent close];
|
||||
// [thisBox removeFromSuperview];
|
||||
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
@class GormSplitViewEditor;
|
||||
|
||||
- (NSArray *)destroyAndListSubviews
|
||||
{
|
||||
if ([parent isKindOfClass: [GormBoxEditor class]]
|
||||
&&
|
||||
([[parent parent] isKindOfClass:
|
||||
[GormViewWithContentViewEditor class]]
|
||||
|| [[parent parent] isKindOfClass:
|
||||
[GormSplitViewEditor class]]))
|
||||
{
|
||||
NSEnumerator *enumerator = [[_editedObject subviews] objectEnumerator];
|
||||
GormViewEditor *subview;
|
||||
NSMutableArray *newSelection = [NSMutableArray array];
|
||||
|
||||
[[parent parent] makeSubeditorResign];
|
||||
|
||||
while ((subview = [enumerator nextObject]) != nil)
|
||||
{
|
||||
id v;
|
||||
NSRect frame;
|
||||
v = [subview editedObject];
|
||||
frame = [v frame];
|
||||
frame = [[parent parent] convertRect: frame
|
||||
fromView: _editedObject];
|
||||
[subview deactivate];
|
||||
|
||||
[v setFrame: frame];
|
||||
// [[[parent parent] editedObject] addSubview: v];
|
||||
[newSelection addObject: v];
|
||||
}
|
||||
|
||||
{
|
||||
id thisView = [parent editedObject];
|
||||
[parent close];
|
||||
[thisView removeFromSuperview];
|
||||
|
||||
}
|
||||
|
||||
return newSelection;
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void) deleteSelection: (id) sender
|
||||
{
|
||||
[self deleteSelection];
|
||||
}
|
||||
|
||||
@end
|
33
GormMatrixEditor.h
Normal file
33
GormMatrixEditor.h
Normal file
|
@ -0,0 +1,33 @@
|
|||
/* GormMatrixEditor.h - Editor for matrices.
|
||||
*
|
||||
* Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
*
|
||||
* Author: Pierre-Yves Rivaille
|
||||
* Date: Aug 2002
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#import "GormViewWithSubviewsEditor.h"
|
||||
|
||||
@interface GormMatrixEditor : GormViewWithSubviewsEditor
|
||||
{
|
||||
NSCell* selected;
|
||||
int selectedRow;
|
||||
int selectedCol;
|
||||
}
|
||||
@end
|
|
@ -2,8 +2,10 @@
|
|||
*
|
||||
* Copyright (C) 2001 Free Software Foundation, Inc.
|
||||
*
|
||||
* Author: Adam Fedor <fedor@gnu.org>
|
||||
* Authors: Adam Fedor <fedor@gnu.org>
|
||||
* Pierre-Yves Rivaille <pyrivail@ens-lyon.fr>
|
||||
* Date: Sep 2001
|
||||
* Aug 2002
|
||||
*
|
||||
* This file is part of GNUstep.
|
||||
*
|
||||
|
@ -24,6 +26,20 @@
|
|||
|
||||
#include "GormPrivate.h"
|
||||
|
||||
#import "GormViewEditor.h"
|
||||
|
||||
#import "GormMatrixEditor.h"
|
||||
#import "GormViewWithSubviewsEditor.h"
|
||||
#import "GormPlacementInfo.h"
|
||||
|
||||
#define _EO ((NSMatrix*)_editedObject)
|
||||
|
||||
|
||||
@interface GormViewEditor (Private)
|
||||
- (void) _displayFrame: (NSRect) frame
|
||||
withPlacementInfo: (GormPlacementInfo*)gpi;
|
||||
@end
|
||||
|
||||
@implementation NSMatrix (GormObjectAdditions)
|
||||
- (NSString*) editorClassName
|
||||
{
|
||||
|
@ -57,21 +73,6 @@
|
|||
|
||||
@implementation GormMatrixEditor
|
||||
|
||||
static NSMapTable *docMap = 0;
|
||||
|
||||
+ (void) initialize
|
||||
{
|
||||
if (self == [GormMatrixEditor class])
|
||||
{
|
||||
docMap = NSCreateMapTable(NSNonRetainedObjectMapKeyCallBacks,
|
||||
NSObjectMapValueCallBacks, 2);
|
||||
}
|
||||
}
|
||||
|
||||
- (id) changeSelection: (id)sender
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void) copySelection
|
||||
{
|
||||
|
@ -83,11 +84,6 @@ static NSMapTable *docMap = 0;
|
|||
}
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
RELEASE(matrix);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void) deleteSelection
|
||||
{
|
||||
|
@ -107,33 +103,19 @@ static BOOL done_editing;
|
|||
NSLog(@"GormMatrixEditor got unhandled notification %@", name);
|
||||
}
|
||||
|
||||
- (id) editedObject
|
||||
{
|
||||
return matrix;
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialisation
|
||||
*/
|
||||
- (id) initWithObject: (id)anObject inDocument: (id<IBDocuments>)aDocument
|
||||
{
|
||||
id old = NSMapGet(docMap, (void*)aDocument);
|
||||
|
||||
if (old != nil)
|
||||
{
|
||||
RELEASE(self);
|
||||
self = RETAIN(old);
|
||||
[self changeObject: anObject];
|
||||
return self;
|
||||
}
|
||||
|
||||
self = [super init];
|
||||
if (self != nil)
|
||||
{
|
||||
document = aDocument;
|
||||
NSMapInsert(docMap, (void*)aDocument, (void*)self);
|
||||
[self changeObject: anObject];
|
||||
}
|
||||
opened = NO;
|
||||
selected = nil;
|
||||
selectedCol = -1;
|
||||
selectedRow = -1;
|
||||
_displaySelection = YES;
|
||||
self = [super initWithObject: anObject
|
||||
inDocument: aDocument];
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -152,27 +134,27 @@ static BOOL done_editing;
|
|||
NSDate *future = [NSDate distantFuture];
|
||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
|
||||
isForm = [matrix isKindOfClass: [NSForm class]];
|
||||
isForm = [_EO isKindOfClass: [NSForm class]];
|
||||
if (isForm == NO && [selected type] != NSTextCellType)
|
||||
return;
|
||||
|
||||
/* FIXME: Seems wierd to do this. */
|
||||
edit_view = [matrix superview];
|
||||
edit_view = [_EO superview];
|
||||
|
||||
[matrix getRow: &row column: &col ofCell: selected];
|
||||
frame = [matrix cellFrameAtRow: row column: col];
|
||||
frame.origin.x += NSMinX([matrix frame]);
|
||||
[_EO getRow: &row column: &col ofCell: selected];
|
||||
frame = [_EO cellFrameAtRow: row column: col];
|
||||
frame.origin.x += NSMinX([_EO frame]);
|
||||
if (isForm)
|
||||
frame.size.width = [(NSForm *)matrix titleWidth];
|
||||
frame.size.width = [(NSForm *)_EO titleWidth];
|
||||
else
|
||||
frame = [selected titleRectForBounds: frame];
|
||||
if ([matrix isFlipped])
|
||||
if ([_EO isFlipped])
|
||||
{
|
||||
frame.origin.y = NSMaxY([matrix frame]) - NSMaxY(frame);
|
||||
frame.origin.y = NSMaxY([_EO frame]) - NSMaxY(frame);
|
||||
}
|
||||
else
|
||||
{
|
||||
frame.origin.y = NSMinY([matrix frame]) + NSMinY(frame);
|
||||
frame.origin.y = NSMinY([_EO frame]) + NSMinY(frame);
|
||||
}
|
||||
|
||||
/* Now create an edit field and allow the user to edit the text */
|
||||
|
@ -252,15 +234,15 @@ static BOOL done_editing;
|
|||
/* Set the new title and resize the form to match the titles */
|
||||
float oldTitleWidth, titleWidth;
|
||||
NSRect oldFrame;
|
||||
oldTitleWidth = [(NSForm *)matrix titleWidth];
|
||||
oldTitleWidth = [(NSForm *)_EO titleWidth];
|
||||
[(NSFormCell *)selected setTitle: [editField stringValue]];
|
||||
[(NSForm *)matrix calcSize];
|
||||
titleWidth = [(NSForm *)matrix titleWidth];
|
||||
oldFrame = frame = [matrix frame];
|
||||
[(NSForm *)_EO calcSize];
|
||||
titleWidth = [(NSForm *)_EO titleWidth];
|
||||
oldFrame = frame = [_EO frame];
|
||||
frame.origin.x -= (titleWidth - oldTitleWidth);
|
||||
frame.size.width += (titleWidth - oldTitleWidth);
|
||||
[(NSForm *)matrix setEntryWidth: NSWidth(frame)];
|
||||
[(NSForm *)matrix setFrame: frame];
|
||||
[(NSForm *)_EO setEntryWidth: NSWidth(frame)];
|
||||
[(NSForm *)_EO setFrame: frame];
|
||||
frame = NSUnionRect(frame, oldFrame);
|
||||
}
|
||||
else
|
||||
|
@ -273,22 +255,106 @@ static BOOL done_editing;
|
|||
RELEASE(editField);
|
||||
}
|
||||
|
||||
- (BOOL) canBeOpened
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void) setOpened: (BOOL) value
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
opened = YES;
|
||||
}
|
||||
else
|
||||
{
|
||||
opened = NO;
|
||||
selected = nil;
|
||||
selectedCol = -1;
|
||||
selectedRow = -1;
|
||||
}
|
||||
}
|
||||
|
||||
- (void) mouseDown: (NSEvent *)theEvent
|
||||
{
|
||||
BOOL onKnob = NO;
|
||||
|
||||
{
|
||||
if ([[parent selection] containsObject: _EO])
|
||||
{
|
||||
IBKnobPosition knob = IBNoneKnobPosition;
|
||||
NSPoint mouseDownPoint =
|
||||
[self convertPoint: [theEvent locationInWindow]
|
||||
fromView: nil];
|
||||
knob = GormKnobHitInRect([self bounds],
|
||||
mouseDownPoint);
|
||||
if (knob != IBNoneKnobPosition)
|
||||
onKnob = YES;
|
||||
}
|
||||
if (onKnob == YES)
|
||||
{
|
||||
if (_next_responder)
|
||||
return [_next_responder mouseDown: theEvent];
|
||||
else
|
||||
return [self noResponderFor: @selector(mouseDown:)];
|
||||
}
|
||||
}
|
||||
|
||||
if (opened == NO)
|
||||
{
|
||||
[super mouseDown: theEvent];
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
int row, col;
|
||||
NSPoint mouseDownPoint =
|
||||
[_EO
|
||||
convertPoint: [theEvent locationInWindow]
|
||||
fromView: nil];
|
||||
|
||||
if ([_EO
|
||||
getRow: &row
|
||||
column: &col
|
||||
forPoint: mouseDownPoint] == YES)
|
||||
{
|
||||
selectedRow = row;
|
||||
selectedCol = col;
|
||||
selected = [_EO cellAtRow: row
|
||||
column: col];
|
||||
|
||||
[document setSelectionFromEditor: self];
|
||||
|
||||
[self setNeedsDisplay: YES];
|
||||
}
|
||||
else
|
||||
{
|
||||
selected = nil;
|
||||
selectedRow = -1;
|
||||
selectedCol = -1;
|
||||
[document setSelectionFromEditor: self];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
- (void) mouseDown: (NSEvent*)theEvent
|
||||
{
|
||||
int row, col;
|
||||
id obj;
|
||||
NSPoint loc = [theEvent locationInWindow];
|
||||
|
||||
/*
|
||||
* Double-click on a cell allows one to edit the cell title
|
||||
*/
|
||||
//
|
||||
// Double-click on a cell allows one to edit the cell title
|
||||
//
|
||||
if (selected != nil && ([theEvent clickCount] == 2) )
|
||||
{
|
||||
[self editTitleWithEvent: theEvent];
|
||||
return;
|
||||
}
|
||||
|
||||
/* Find which cell the mouse is in */
|
||||
// Find which cell the mouse is in
|
||||
loc = [matrix convertPoint: loc fromView: nil];
|
||||
if ([matrix getRow: &row column: &col forPoint: loc] == NO)
|
||||
return;
|
||||
|
@ -299,36 +365,32 @@ static BOOL done_editing;
|
|||
[self selectObjects: [NSArray arrayWithObject: obj]];
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
- (void) makeSelectionVisible: (BOOL)flag
|
||||
{
|
||||
if (selected != nil)
|
||||
{
|
||||
int row, col;
|
||||
if ([matrix getRow: &row column: &col ofCell: selected])
|
||||
if ([_EO getRow: &row column: &col ofCell: selected])
|
||||
{
|
||||
NSRect frame = [matrix cellFrameAtRow: row column: col];
|
||||
NSRect frame = [_EO cellFrameAtRow: row column: col];
|
||||
if (flag == YES)
|
||||
[matrix selectCellAtRow: row column: col];
|
||||
[matrix lockFocus];
|
||||
[_EO selectCellAtRow: row column: col];
|
||||
[_EO lockFocus];
|
||||
[[NSColor controlShadowColor] set];
|
||||
NSHighlightRect(frame);
|
||||
[matrix unlockFocus];
|
||||
[_EO unlockFocus];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
[matrix deselectAllCells];
|
||||
[_EO deselectAllCells];
|
||||
}
|
||||
[matrix display];
|
||||
[[matrix window] flushWindow];
|
||||
[_EO display];
|
||||
[[_EO window] flushWindow];
|
||||
}
|
||||
|
||||
- (void) changeObject: anObject
|
||||
{
|
||||
ASSIGN(matrix, anObject);
|
||||
selected = nil;
|
||||
}
|
||||
|
||||
- (void) selectObjects: (NSArray*)anArray
|
||||
{
|
||||
|
@ -342,20 +404,20 @@ static BOOL done_editing;
|
|||
- (NSArray*) selection
|
||||
{
|
||||
if (selected == nil)
|
||||
return [NSArray array];
|
||||
return [NSArray arrayWithObject: _EO];
|
||||
else
|
||||
return [NSArray arrayWithObject: selected];
|
||||
}
|
||||
|
||||
- (unsigned) selectionCount
|
||||
{
|
||||
return (selected == nil) ? 0 : 1;
|
||||
}
|
||||
// - (unsigned) selectionCount
|
||||
// {
|
||||
// return (selected == nil) ? 0 : 1;
|
||||
// }
|
||||
|
||||
- (id<IBEditors>) openSubeditorForObject: (id)anObject
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
// - (id<IBEditors>) openSubeditorForObject: (id)anObject
|
||||
// {
|
||||
// return nil;
|
||||
// }
|
||||
|
||||
- (BOOL) acceptsTypeFromArray: (NSArray*)types
|
||||
{
|
||||
|
@ -364,11 +426,7 @@ static BOOL done_editing;
|
|||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL) activate
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
/*
|
||||
- (void) close
|
||||
{
|
||||
[self deactivate];
|
||||
|
@ -378,51 +436,260 @@ static BOOL done_editing;
|
|||
- (void) closeSubeditors
|
||||
{
|
||||
}
|
||||
*/
|
||||
|
||||
- (void) deactivate
|
||||
|
||||
- (void) postDraw: (NSRect) rect
|
||||
{
|
||||
selected = nil;
|
||||
if (_displaySelection)
|
||||
{
|
||||
if ((selectedRow != -1) && (selectedCol != -1))
|
||||
{
|
||||
NSLog(@"highlighting %@",
|
||||
NSStringFromRect([_EO
|
||||
cellFrameAtRow: selectedRow
|
||||
column: selectedCol]));
|
||||
[[NSColor blackColor] set];
|
||||
NSHighlightRect([_EO
|
||||
convertRect:
|
||||
[_EO
|
||||
cellFrameAtRow: selectedRow
|
||||
column: selectedCol]
|
||||
toView: self]);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void) drawSelection
|
||||
|
||||
|
||||
|
||||
- (NSRect) _constrainedFrame: (NSRect) frame
|
||||
withEvent: (NSEvent *)theEvent
|
||||
andKnob: (IBKnobPosition) knob
|
||||
{
|
||||
int width;
|
||||
int height;
|
||||
|
||||
if ([theEvent modifierFlags] & NSAlternateKeyMask)
|
||||
{
|
||||
int rows = [_EO numberOfRows];
|
||||
int cols = [_EO numberOfColumns];
|
||||
NSSize interSize = [_EO intercellSpacing];
|
||||
|
||||
int colWidth = ([_EO frame].size.width -
|
||||
(cols - 1) * interSize.width) / cols;
|
||||
int rowHeight = ([_EO frame].size.height -
|
||||
(rows - 1) * interSize.height) / rows;
|
||||
|
||||
int widthIncrement = colWidth + interSize.width;
|
||||
int heightIncrement = rowHeight + interSize.height;
|
||||
|
||||
if (frame.size.width < colWidth)
|
||||
{
|
||||
width = colWidth;
|
||||
rows = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
width = frame.size.width - [_EO frame].size.width;
|
||||
rows = width / widthIncrement;
|
||||
width = rows * widthIncrement + [_EO frame].size.width;
|
||||
}
|
||||
|
||||
if (frame.size.height < rowHeight)
|
||||
{
|
||||
height = rowHeight;
|
||||
cols = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
height = frame.size.height - [_EO frame].size.height;
|
||||
cols = height / heightIncrement;
|
||||
height = cols * heightIncrement + [_EO frame].size.height;
|
||||
}
|
||||
}
|
||||
else if ([theEvent modifierFlags] & NSControlKeyMask)
|
||||
{
|
||||
int rows = [_EO numberOfRows];
|
||||
int cols = [_EO numberOfColumns];
|
||||
NSSize cellSize = [_EO cellSize];
|
||||
|
||||
|
||||
width = ( frame.size.width - cellSize.width * cols) / (cols - 1);
|
||||
height = ( frame.size.height - cellSize.height * rows ) / (rows - 1);
|
||||
|
||||
width *= (cols - 1);
|
||||
width += cellSize.width * cols;
|
||||
height *= (rows - 1);
|
||||
height += cellSize.height * rows;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
int rows = [_EO numberOfRows];
|
||||
int cols = [_EO numberOfColumns];
|
||||
NSSize interSize = [_EO intercellSpacing];
|
||||
|
||||
width = ( frame.size.width - interSize.width * (cols - 1) ) / cols;
|
||||
width *= cols;
|
||||
width += (interSize.width * (cols - 1));
|
||||
|
||||
height = ( frame.size.height - interSize.height * (rows - 1) ) / rows;
|
||||
height *= rows;
|
||||
height += (interSize.height * (rows - 1));
|
||||
}
|
||||
|
||||
switch (knob)
|
||||
{
|
||||
case IBBottomLeftKnobPosition:
|
||||
case IBMiddleLeftKnobPosition:
|
||||
case IBTopLeftKnobPosition:
|
||||
frame.origin.x = NSMaxX(frame) - width;
|
||||
frame.size.width = width;
|
||||
break;
|
||||
case IBTopRightKnobPosition:
|
||||
case IBMiddleRightKnobPosition:
|
||||
case IBBottomRightKnobPosition:
|
||||
frame.size.width = width;
|
||||
break;
|
||||
case IBTopMiddleKnobPosition:
|
||||
case IBBottomMiddleKnobPosition:
|
||||
case IBNoneKnobPosition:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
switch (knob)
|
||||
{
|
||||
case IBBottomLeftKnobPosition:
|
||||
case IBBottomRightKnobPosition:
|
||||
case IBBottomMiddleKnobPosition:
|
||||
frame.origin.y = NSMaxY(frame) - height;
|
||||
frame.size.height = height;
|
||||
break;
|
||||
case IBTopMiddleKnobPosition:
|
||||
case IBTopRightKnobPosition:
|
||||
case IBTopLeftKnobPosition:
|
||||
frame.size.height = height;
|
||||
break;
|
||||
case IBMiddleLeftKnobPosition:
|
||||
case IBMiddleRightKnobPosition:
|
||||
case IBNoneKnobPosition:
|
||||
break;
|
||||
}
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
- (id<IBDocuments>) document
|
||||
|
||||
- (void) updateResizingWithFrame: (NSRect) frame
|
||||
andEvent: (NSEvent *)theEvent
|
||||
andPlacementInfo: (GormPlacementInfo*) gpi
|
||||
{
|
||||
return document;
|
||||
gpi->lastFrame = [self _constrainedFrame: frame
|
||||
withEvent: theEvent
|
||||
andKnob: gpi->knob];
|
||||
|
||||
[self _displayFrame: gpi->lastFrame
|
||||
withPlacementInfo: gpi];
|
||||
}
|
||||
|
||||
- (void) orderFront
|
||||
{
|
||||
NSLog(@"Ack - GormMatrixEditor - orderFront");
|
||||
}
|
||||
|
||||
- (void) pasteInSelection
|
||||
{
|
||||
}
|
||||
|
||||
- (void) resetObject: (id)anObject
|
||||
- (void) validateFrame: (NSRect) frame
|
||||
withEvent: (NSEvent *) theEvent
|
||||
andPlacementInfo: (GormPlacementInfo*)gpi
|
||||
{
|
||||
[self changeObject: anObject];
|
||||
selected = nil;
|
||||
}
|
||||
frame = gpi->lastFrame;
|
||||
|
||||
- (void) validateEditing
|
||||
{
|
||||
}
|
||||
if ([theEvent modifierFlags] & NSAlternateKeyMask)
|
||||
{
|
||||
int rows = [_EO numberOfRows];
|
||||
int cols = [_EO numberOfColumns];
|
||||
NSSize interSize = [_EO intercellSpacing];
|
||||
|
||||
int colWidth = ([_EO frame].size.width -
|
||||
(cols - 1) * interSize.width) / cols;
|
||||
int rowHeight = ([_EO frame].size.height -
|
||||
(rows - 1) * interSize.height) / rows;
|
||||
|
||||
int widthIncrement = colWidth + interSize.width;
|
||||
int heightIncrement = rowHeight + interSize.height;
|
||||
|
||||
- (BOOL) wantsSelection
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
int newCols = (frame.size.width - [_EO frame].size.width) /
|
||||
widthIncrement;
|
||||
int newRows = (frame.size.height - [_EO frame].size.height) /
|
||||
heightIncrement;
|
||||
|
||||
int i;
|
||||
|
||||
- (NSWindow*) window
|
||||
{
|
||||
NSLog(@"Ack - GormMatrix - window");
|
||||
return nil;
|
||||
}
|
||||
if (newCols > 0)
|
||||
{
|
||||
for ( i = 0; i < newCols; i++)
|
||||
{
|
||||
[_EO addColumn];
|
||||
}
|
||||
}
|
||||
else if (newCols < 0)
|
||||
{
|
||||
for ( i = 0; i < -newCols; i++)
|
||||
{
|
||||
[_EO removeColumn: cols - i - 1];
|
||||
}
|
||||
}
|
||||
|
||||
if (newRows > 0)
|
||||
{
|
||||
for ( i = 0; i < newRows; i++)
|
||||
{
|
||||
[_EO addRow];
|
||||
}
|
||||
}
|
||||
else if (newRows < 0)
|
||||
{
|
||||
for ( i = 0; i < -newRows; i++)
|
||||
{
|
||||
[_EO removeRow: rows - i - 1];
|
||||
}
|
||||
}
|
||||
[_EO setFrame: frame];
|
||||
}
|
||||
else if ([theEvent modifierFlags] & NSControlKeyMask)
|
||||
{
|
||||
int width;
|
||||
int height;
|
||||
int rows = [_EO numberOfRows];
|
||||
int cols = [_EO numberOfColumns];
|
||||
NSSize cellSize = [_EO cellSize];
|
||||
|
||||
|
||||
[self setFrame: frame];
|
||||
|
||||
|
||||
width = ( frame.size.width - cellSize.width * cols) / (cols - 1);
|
||||
height = ( frame.size.height - cellSize.height * rows ) / (rows - 1);
|
||||
|
||||
[_EO setIntercellSpacing: NSMakeSize(width, height)];
|
||||
}
|
||||
else
|
||||
{
|
||||
int width;
|
||||
int height;
|
||||
int rows = [_EO numberOfRows];
|
||||
int cols = [_EO numberOfColumns];
|
||||
NSSize interSize = [_EO intercellSpacing];
|
||||
|
||||
|
||||
[self setFrame: frame];
|
||||
|
||||
|
||||
width = ( frame.size.width - interSize.width * (cols - 1) ) / cols;
|
||||
height = ( frame.size.height - interSize.height * (rows - 1) ) / rows;
|
||||
|
||||
[_EO setCellSize: NSMakeSize(width, height)];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -285,8 +285,8 @@ static NSMapTable *docMap = 0;
|
|||
|
||||
- (void) handleNotification: (NSNotification*)aNotification
|
||||
{
|
||||
id object = [aNotification object];
|
||||
NSString *name = [aNotification name];
|
||||
// id object = [aNotification object];
|
||||
// NSString *name = [aNotification name];
|
||||
|
||||
}
|
||||
|
||||
|
@ -656,9 +656,6 @@ static NSMapTable *docMap = 0;
|
|||
return (selected == nil) ? 0 : 1;
|
||||
}
|
||||
|
||||
- (void) validateEditing
|
||||
{
|
||||
}
|
||||
|
||||
- (BOOL) wantsSelection
|
||||
{
|
||||
|
|
|
@ -554,7 +554,7 @@ static NSColor *darkGreyBlueColor = nil;
|
|||
}
|
||||
else if(isActionOrOutlet)
|
||||
{
|
||||
NSString *name = [_clickedItem getName];
|
||||
// NSString *name = [_clickedItem getName];
|
||||
}
|
||||
|
||||
[super mouseDown: theEvent];
|
||||
|
|
72
GormPlacementInfo.h
Normal file
72
GormPlacementInfo.h
Normal file
|
@ -0,0 +1,72 @@
|
|||
/* GormPlacementInfo.h
|
||||
*
|
||||
* Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
*
|
||||
* Author: Pierre-Yves Rivaille <pyrivail@ens-lyon.fr>
|
||||
* Date: 2002
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
@interface GormPlacementInfo : NSObject
|
||||
{
|
||||
@public
|
||||
NSView *resizingIn;
|
||||
NSRect oldRect;
|
||||
BOOL firstPass;
|
||||
BOOL hintInitialized;
|
||||
NSMutableArray *leftHints;
|
||||
NSMutableArray *rightHints;
|
||||
NSMutableArray *topHints;
|
||||
NSMutableArray *bottomHints;
|
||||
NSRect lastLeftRect;
|
||||
NSRect lastRightRect;
|
||||
NSRect lastTopRect;
|
||||
NSRect lastBottomRect;
|
||||
NSRect hintFrame;
|
||||
NSRect lastFrame;
|
||||
IBKnobPosition knob;
|
||||
}
|
||||
@end
|
||||
|
||||
typedef enum _GormHintBorder
|
||||
{
|
||||
Top, Bottom, Left, Right
|
||||
} GormHintBorder;
|
||||
|
||||
@interface GormPlacementHint : NSObject
|
||||
{
|
||||
GormHintBorder _border;
|
||||
float _position;
|
||||
float _start;
|
||||
float _end;
|
||||
NSRect _frame;
|
||||
}
|
||||
- (id) initWithBorder: (GormHintBorder) border
|
||||
position: (float) position
|
||||
validityStart: (float) start
|
||||
validityEnd: (float) end
|
||||
frame: (NSRect) frame;
|
||||
- (NSRect) rectWithHalfDistance: (int) halfDistance;
|
||||
- (int) distanceToFrame: (NSRect) frame;
|
||||
- (float) position;
|
||||
- (float) start;
|
||||
- (float) end;
|
||||
- (NSRect) frame;
|
||||
- (GormHintBorder) border;
|
||||
@end
|
||||
|
7
GormPosingView.h
Normal file
7
GormPosingView.h
Normal file
|
@ -0,0 +1,7 @@
|
|||
#import <AppKit/AppKit.h>
|
||||
|
||||
@interface GormPosingView : NSView
|
||||
{
|
||||
|
||||
}
|
||||
@end
|
89
GormPosingView.m
Normal file
89
GormPosingView.m
Normal file
|
@ -0,0 +1,89 @@
|
|||
#import "GormPosingView.h"
|
||||
|
||||
|
||||
@implementation GormPosingView
|
||||
|
||||
struct _rFlagsType2 {
|
||||
/*
|
||||
* 'flipped_view' is set in NSViews designated initialiser (and other
|
||||
* methods that create views) to be the value returned by [-isFlipped]
|
||||
* This caching assumes that the value returned by [-isFlipped] will
|
||||
* not change during the views lifetime - if it does, the view must
|
||||
* be sure to change the flag accordingly.
|
||||
*/
|
||||
unsigned flipped_view:1;
|
||||
unsigned has_subviews:1; /* The view has subviews. */
|
||||
unsigned has_currects:1; /* The view has cursor rects. */
|
||||
unsigned has_trkrects:1; /* The view has tracking rects. */
|
||||
unsigned has_draginfo:1; /* View/window has drag types. */
|
||||
unsigned opaque_view:1; /* For views whose opacity may */
|
||||
/* change to keep track of it. */
|
||||
unsigned valid_rects:1; /* Some cursor rects may be ok. */
|
||||
unsigned needs_display:1; /* Window/view needs display. */
|
||||
unsigned isCustom:1;
|
||||
} ;
|
||||
|
||||
|
||||
- (id) initWithFrame: (NSRect)frameRect
|
||||
{
|
||||
struct _rFlagsType2 *rft2;
|
||||
|
||||
rft2 = (struct _rFlagsType2 *) &_rFlags;
|
||||
|
||||
rft2->isCustom = 0;
|
||||
|
||||
[super initWithFrame: frameRect];
|
||||
}
|
||||
|
||||
- (void) viewWillMoveToWindow: (NSWindow*)newWindow
|
||||
{
|
||||
if ([newWindow isKindOfClass: NSClassFromString(@"GormNSWindow")])
|
||||
{
|
||||
[self setCustom: YES];
|
||||
}
|
||||
[super viewWillMoveToWindow: newWindow];
|
||||
|
||||
}
|
||||
|
||||
- (BOOL) isCustom
|
||||
{
|
||||
struct _rFlagsType2 *rft2;
|
||||
|
||||
rft2 = (struct _rFlagsType2 *) &_rFlags;
|
||||
|
||||
if (rft2->isCustom == 0)
|
||||
return NO;
|
||||
else
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void) display
|
||||
{
|
||||
if ([self isCustom])
|
||||
{
|
||||
NSLog(@"%@ display", self);
|
||||
}
|
||||
[super display];
|
||||
}
|
||||
|
||||
- (void) displayIfNeeded
|
||||
{
|
||||
if ([self isCustom])
|
||||
{
|
||||
NSLog(@"%@ displayIfNeeded", self);
|
||||
}
|
||||
[super displayIfNeeded];
|
||||
}
|
||||
|
||||
- (void) setCustom: (BOOL) value
|
||||
{
|
||||
struct _rFlagsType2 *rft2;
|
||||
|
||||
rft2 = (struct _rFlagsType2 *) &_rFlags;
|
||||
if (value)
|
||||
rft2->isCustom = 1;
|
||||
else
|
||||
rft2->isCustom = 0;
|
||||
}
|
||||
|
||||
@end
|
|
@ -119,7 +119,7 @@ extern NSString *GormLinkPboardType;
|
|||
- (void) setSelectedClassName: (NSString*)cn;
|
||||
@end
|
||||
|
||||
@interface GormObjectEditor : NSMatrix <IBEditors>
|
||||
@interface GormObjectEditor : NSMatrix <IBEditors, IBSelectionOwners>
|
||||
{
|
||||
NSMutableArray *objects;
|
||||
id<IBDocuments> document;
|
||||
|
@ -150,28 +150,10 @@ extern NSString *GormLinkPboardType;
|
|||
- (NSRect) rectForObject: (id)anObject;
|
||||
- (void) resetObject: (id)anObject;
|
||||
- (void) selectObjects: (NSArray*)objects;
|
||||
- (void) validateEditing;
|
||||
- (BOOL) wantsSelection;
|
||||
- (NSWindow*) window;
|
||||
@end
|
||||
|
||||
@interface GormMatrixEditor : NSObject <IBEditors>
|
||||
{
|
||||
id<IBDocuments> document;
|
||||
id selected;
|
||||
NSMatrix *matrix;
|
||||
}
|
||||
|
||||
- (void) changeObject: anObject;
|
||||
@end
|
||||
|
||||
@interface GormTableViewEditor : NSObject <IBEditors>
|
||||
{
|
||||
id<IBDocuments> document;
|
||||
id selected;
|
||||
NSTableView *tableView;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface GormFilesOwnerInspector : IBInspector
|
||||
{
|
||||
|
|
31
GormSplitViewEditor.h
Normal file
31
GormSplitViewEditor.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
/* GormSplitViewEditor.h - Editor for splitviews.
|
||||
*
|
||||
* Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
*
|
||||
* Author: Pierre-Yves Rivaille
|
||||
* Date: Aug 2002
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#import "GormViewWithSubviewsEditor.h"
|
||||
|
||||
@interface GormSplitViewEditor : GormViewWithSubviewsEditor
|
||||
{
|
||||
}
|
||||
- (NSArray *)destroyAndListSubviews;
|
||||
@end
|
460
GormSplitViewEditor.m
Normal file
460
GormSplitViewEditor.m
Normal file
|
@ -0,0 +1,460 @@
|
|||
/* GormSplitViewEditor.m
|
||||
*
|
||||
* Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
*
|
||||
* Author: Pierre-Yves Rivaille <pyrivail@ens-lyon.fr>
|
||||
* Date: 2002
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#import <AppKit/AppKit.h>
|
||||
|
||||
#include "GormPrivate.h"
|
||||
|
||||
#import "GormSplitViewEditor.h"
|
||||
#import "GormInternalViewEditor.h"
|
||||
#import "GormBoxEditor.h"
|
||||
|
||||
#define _EO ((NSSplitView *)_editedObject)
|
||||
|
||||
@implementation NSSplitView (GormObjectAdditions)
|
||||
- (NSString*) editorClassName
|
||||
{
|
||||
return @"GormSplitViewEditor";
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
@implementation GormSplitViewEditor
|
||||
|
||||
- (id) initWithObject: (id) anObject
|
||||
inDocument: (id<IBDocuments>) aDocument
|
||||
{
|
||||
|
||||
opened = NO;
|
||||
_displaySelection = YES;
|
||||
|
||||
self = [super initWithObject: anObject
|
||||
inDocument: aDocument];
|
||||
|
||||
[self registerForDraggedTypes: [NSArray arrayWithObjects:
|
||||
IBViewPboardType, GormLinkPboardType, IBFormatterPboardType, nil]];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL) activate
|
||||
{
|
||||
if ([super activate])
|
||||
{
|
||||
NSEnumerator *enumerator;
|
||||
NSView *sub;
|
||||
|
||||
NSLog(@"activating %@ GormSplitViewEditor %@", self, _EO);
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver: self
|
||||
selector: @selector(splitViewDidResizeSubviews:)
|
||||
name: NSSplitViewDidResizeSubviewsNotification
|
||||
object: _EO];
|
||||
|
||||
enumerator = [[NSArray arrayWithArray: [_EO subviews]]
|
||||
objectEnumerator];
|
||||
|
||||
while ((sub = [enumerator nextObject]) != nil)
|
||||
{
|
||||
NSLog(@"ac %@ editorForObject: %@", self, sub);
|
||||
if ([sub isKindOfClass: [GormViewEditor class]] == NO)
|
||||
{
|
||||
NSLog(@"ac %@ yes", self);
|
||||
[document editorForObject: sub
|
||||
inEditor: self
|
||||
create: YES];
|
||||
}
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void) deactivate
|
||||
{
|
||||
if (activated == YES)
|
||||
{
|
||||
[self deactivateSubeditors];
|
||||
openedSubeditor = nil;
|
||||
[[NSNotificationCenter defaultCenter] removeObserver: self];
|
||||
[super deactivate];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) validateFrame: (NSRect) frame
|
||||
withEvent: (NSEvent *) theEvent
|
||||
andPlacementInfo: (GormPlacementInfo *) gpi
|
||||
{
|
||||
[super validateFrame: frame
|
||||
withEvent: theEvent
|
||||
andPlacementInfo: gpi];
|
||||
[_EO adjustSubviews];
|
||||
}
|
||||
|
||||
|
||||
|
||||
- (BOOL) acceptsTypeFromArray: (NSArray*)types
|
||||
{
|
||||
if ([super acceptsTypeFromArray: types])
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
else
|
||||
{
|
||||
return [types containsObject: IBViewPboardType];
|
||||
}
|
||||
}
|
||||
|
||||
- (unsigned) draggingEntered: (id<NSDraggingInfo>)sender
|
||||
{
|
||||
NSPasteboard *dragPb;
|
||||
NSArray *types;
|
||||
|
||||
dragPb = [sender draggingPasteboard];
|
||||
types = [dragPb types];
|
||||
if ([types containsObject: GormLinkPboardType] == YES)
|
||||
{
|
||||
[NSApp displayConnectionBetween: [NSApp connectSource]
|
||||
and: _EO];
|
||||
return NSDragOperationLink;
|
||||
}
|
||||
else if ([types containsObject: IBViewPboardType] == YES)
|
||||
{
|
||||
return NSDragOperationCopy;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NSDragOperationNone;
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL) prepareForDragOperation: (id<NSDraggingInfo>)sender
|
||||
{
|
||||
NSPasteboard *dragPb;
|
||||
NSArray *types;
|
||||
|
||||
dragPb = [sender draggingPasteboard];
|
||||
types = [dragPb types];
|
||||
if ([types containsObject: GormLinkPboardType] == YES)
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
else if ([types containsObject: IBViewPboardType] == YES)
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
- (unsigned) draggingUpdated: (id<NSDraggingInfo>)sender
|
||||
{
|
||||
NSPasteboard *dragPb;
|
||||
NSArray *types;
|
||||
|
||||
dragPb = [sender draggingPasteboard];
|
||||
types = [dragPb types];
|
||||
if ([types containsObject: GormLinkPboardType] == YES)
|
||||
{
|
||||
[NSApp displayConnectionBetween: [NSApp connectSource]
|
||||
and: _EO];
|
||||
return NSDragOperationLink;
|
||||
}
|
||||
else if ([types containsObject: IBViewPboardType] == YES)
|
||||
{
|
||||
/*
|
||||
NSArray *sub = [_EO subviews];
|
||||
int count = [sub count];
|
||||
NSPoint loc = [sender draggingLocation];
|
||||
loc = [_EO
|
||||
convertPoint: loc fromView: nil];
|
||||
|
||||
if ([_EO isVertical])
|
||||
{
|
||||
for ( i = 0; i < count - 1; i++ )
|
||||
{
|
||||
if (i <
|
||||
}
|
||||
}
|
||||
*/
|
||||
return NSDragOperationCopy;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NSDragOperationNone;
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL) performDragOperation: (id<NSDraggingInfo>)sender
|
||||
{
|
||||
NSPasteboard *dragPb;
|
||||
NSArray *types;
|
||||
|
||||
dragPb = [sender draggingPasteboard];
|
||||
types = [dragPb types];
|
||||
|
||||
if ([types containsObject: GormLinkPboardType])
|
||||
{
|
||||
[NSApp displayConnectionBetween: [NSApp connectSource]
|
||||
and: _EO];
|
||||
[NSApp startConnecting];
|
||||
}
|
||||
else if ([types containsObject: IBViewPboardType] == YES)
|
||||
{
|
||||
NSArray *views;
|
||||
NSEnumerator *enumerator;
|
||||
NSView *sub;
|
||||
|
||||
views = [document pasteType: IBViewPboardType
|
||||
fromPasteboard: dragPb
|
||||
parent: _EO];
|
||||
|
||||
enumerator = [views objectEnumerator];
|
||||
while ((sub = [enumerator nextObject]) != nil)
|
||||
{
|
||||
[_EO addSubview: sub];
|
||||
|
||||
[document editorForObject: sub
|
||||
inEditor: self
|
||||
create: YES];
|
||||
}
|
||||
[_EO adjustSubviews];
|
||||
[_EO setNeedsDisplay: YES];
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
- (void) mouseDown: (NSEvent *) theEvent
|
||||
{
|
||||
BOOL onKnob = NO;
|
||||
NSView *clickedSubview;
|
||||
|
||||
// NSLog(@"in GormSplitViewEditor -mouseDown");
|
||||
{
|
||||
if ([parent respondsToSelector: @selector(selection)] &&
|
||||
[[parent selection] containsObject: _EO])
|
||||
{
|
||||
IBKnobPosition knob = IBNoneKnobPosition;
|
||||
NSPoint mouseDownPoint =
|
||||
[self convertPoint: [theEvent locationInWindow]
|
||||
fromView: nil];
|
||||
knob = GormKnobHitInRect([self bounds],
|
||||
mouseDownPoint);
|
||||
if (knob != IBNoneKnobPosition)
|
||||
onKnob = YES;
|
||||
}
|
||||
if (onKnob == YES)
|
||||
{
|
||||
if (parent)
|
||||
return [parent mouseDown: theEvent];
|
||||
else
|
||||
return [self noResponderFor: @selector(mouseDown:)];
|
||||
}
|
||||
}
|
||||
|
||||
if (opened == NO)
|
||||
{
|
||||
// NSLog(@"not opened");
|
||||
[super mouseDown: theEvent];
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
int i;
|
||||
NSArray *subs = [_EO subviews];
|
||||
int count = [subs count];
|
||||
NSPoint mouseDownPoint =
|
||||
[self convertPoint: [theEvent locationInWindow]
|
||||
fromView: nil];
|
||||
clickedSubview = [_EO hitTest: mouseDownPoint];
|
||||
|
||||
for ( i = 0; i < count; i++ )
|
||||
{
|
||||
if ([clickedSubview isDescendantOf: [subs objectAtIndex: i]])
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i < count)
|
||||
clickedSubview = [subs objectAtIndex: i];
|
||||
else
|
||||
{
|
||||
clickedSubview = nil;
|
||||
// NSLog(@"subs %@", subs);
|
||||
}
|
||||
}
|
||||
|
||||
if (clickedSubview == nil)
|
||||
{
|
||||
// NSLog(@"clickedSubview == nil");
|
||||
if (openedSubeditor)
|
||||
[openedSubeditor deactivate];
|
||||
[_EO mouseDown: theEvent];
|
||||
}
|
||||
else
|
||||
{
|
||||
// NSLog(@"clickedSubview == %@", clickedSubview);
|
||||
// if ([theEvent clickCount] == 2
|
||||
// && [clickedSubview respondsToSelector: @selector(canBeOpened)]
|
||||
// && ([clickedSubview canBeOpened] == YES)
|
||||
// && (clickedSubview != self))
|
||||
[self selectObjects: [NSArray arrayWithObject: clickedSubview]];
|
||||
[self setNeedsDisplay: YES];
|
||||
|
||||
if ([theEvent clickCount] == 2
|
||||
&& [clickedSubview isKindOfClass: [GormViewWithSubviewsEditor class]]
|
||||
&& ([(GormViewWithSubviewsEditor *) clickedSubview canBeOpened] == YES)
|
||||
&& (clickedSubview != self))
|
||||
{
|
||||
if ((openedSubeditor != (GormViewWithSubviewsEditor *)clickedSubview)
|
||||
&& openedSubeditor)
|
||||
[openedSubeditor deactivate];
|
||||
|
||||
[self setOpenedSubeditor: (GormViewWithSubviewsEditor *)clickedSubview];
|
||||
if ([(GormViewWithSubviewsEditor *) clickedSubview isOpened] == NO)
|
||||
[(GormViewWithSubviewsEditor *)clickedSubview setOpened: YES];
|
||||
// NSLog(@"md %@ sendind to clickView %@", self, clickedSubview);
|
||||
[clickedSubview mouseDown: theEvent];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void) splitViewDidResizeSubviews: (NSNotification *)aNotification
|
||||
{
|
||||
[self setNeedsDisplay: YES];
|
||||
}
|
||||
|
||||
|
||||
- (void) ungroup
|
||||
{
|
||||
NSView *toUngroup;
|
||||
|
||||
|
||||
if ([selection count] != 1)
|
||||
return;
|
||||
|
||||
|
||||
toUngroup = [selection objectAtIndex: 0];
|
||||
|
||||
|
||||
if ([toUngroup isKindOfClass: [GormBoxEditor class]]
|
||||
|| [toUngroup isKindOfClass: [GormSplitViewEditor class]])
|
||||
{
|
||||
id contentView = toUngroup;;
|
||||
|
||||
NSMutableArray *newSelection = [NSMutableArray array];
|
||||
NSArray *views;
|
||||
int i;
|
||||
views = [contentView destroyAndListSubviews];
|
||||
for (i = 0; i < [views count]; i++)
|
||||
{
|
||||
[_editedObject addSubview: [views objectAtIndex: i]];
|
||||
[newSelection addObject:
|
||||
[document editorForObject: [views objectAtIndex: i]
|
||||
inEditor: self
|
||||
create: YES]];
|
||||
}
|
||||
[_EO adjustSubviews];
|
||||
[self setNeedsDisplay: YES];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
- (NSArray *)destroyAndListSubviews
|
||||
{
|
||||
NSEnumerator *enumerator = [[_EO subviews] objectEnumerator];
|
||||
GormViewEditor *subview;
|
||||
NSMutableArray *newSelection = [NSMutableArray array];
|
||||
|
||||
[parent makeSubeditorResign];
|
||||
|
||||
while ((subview = [enumerator nextObject]) != nil)
|
||||
{
|
||||
id v;
|
||||
NSRect frame;
|
||||
v = [subview editedObject];
|
||||
frame = [v frame];
|
||||
frame = [parent convertRect: frame
|
||||
fromView: _EO];
|
||||
[subview deactivate];
|
||||
|
||||
[v setFrame: frame];
|
||||
// [[[parent parent] editedObject] addSubview: v];
|
||||
[newSelection addObject: v];
|
||||
}
|
||||
|
||||
{
|
||||
id thisView = [self editedObject];
|
||||
[self close];
|
||||
[thisView removeFromSuperview];
|
||||
|
||||
}
|
||||
return newSelection;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
- (void) postDraw: (NSRect) rect
|
||||
{
|
||||
[super postDraw: rect];
|
||||
|
||||
if (openedSubeditor != nil)
|
||||
{
|
||||
GormDrawOpenKnobsForRect(
|
||||
[self convertRect: [openedSubeditor bounds]
|
||||
fromView: openedSubeditor]);
|
||||
GormShowFastKnobFills();
|
||||
}
|
||||
else if (_displaySelection)
|
||||
{
|
||||
// FIXME
|
||||
}
|
||||
}
|
||||
|
||||
- (void) postDrawForView: (GormViewEditor *) viewEditor
|
||||
{
|
||||
if (_displaySelection == NO)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if ((openedSubeditor == viewEditor) && (openedSubeditor != nil))
|
||||
{
|
||||
GormDrawOpenKnobsForRect([viewEditor bounds]);
|
||||
GormShowFastKnobFills();
|
||||
}
|
||||
else
|
||||
{
|
||||
// FIXME
|
||||
}
|
||||
}
|
||||
*/
|
||||
@end
|
34
GormTabViewEditor.h
Normal file
34
GormTabViewEditor.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
/* GormTabViewEditor.h - Editor for tabviews.
|
||||
*
|
||||
* Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
*
|
||||
* Author: Pierre-Yves Rivaille
|
||||
* Date: Aug 2002
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#import "GormViewWithSubviewsEditor.h"
|
||||
|
||||
#import "GormInternalViewEditor.h"
|
||||
|
||||
@interface GormTabViewEditor : GormViewWithSubviewsEditor
|
||||
{
|
||||
int selectedSubview;
|
||||
GormInternalViewEditor *currentView;
|
||||
}
|
||||
@end
|
192
GormTabViewEditor.m
Normal file
192
GormTabViewEditor.m
Normal file
|
@ -0,0 +1,192 @@
|
|||
/* GormTabViewEditor.m
|
||||
*
|
||||
* Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
*
|
||||
* Author: Pierre-Yves Rivaille <pyrivail@ens-lyon.fr>
|
||||
* Date: 2002
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#import <AppKit/AppKit.h>
|
||||
|
||||
#include "GormPrivate.h"
|
||||
|
||||
#import "GormTabViewEditor.h"
|
||||
|
||||
|
||||
#define _EO ((NSTabView *)_editedObject)
|
||||
|
||||
@implementation NSTabView (GormObjectAdditions)
|
||||
- (NSString*) editorClassName
|
||||
{
|
||||
return @"GormTabViewEditor";
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
@implementation GormTabViewEditor
|
||||
|
||||
- (void) setOpened: (BOOL) flag
|
||||
{
|
||||
[super setOpened: flag];
|
||||
if (flag == YES && currentView)
|
||||
{
|
||||
[document setSelectionFromEditor: currentView];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSArray *) selection
|
||||
{
|
||||
return [NSArray arrayWithObject: _EO];
|
||||
}
|
||||
|
||||
- (BOOL) activate
|
||||
{
|
||||
if ([super activate])
|
||||
{
|
||||
currentView = nil;
|
||||
[_EO setDelegate: self];
|
||||
[self
|
||||
tabView: _EO
|
||||
didSelectTabViewItem: [_EO selectedTabViewItem]];
|
||||
return YES;
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void) deactivate
|
||||
{
|
||||
if (activated == YES)
|
||||
{
|
||||
[self deactivateSubeditors];
|
||||
[_EO setDelegate: nil];
|
||||
[super deactivate];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
- (void) mouseDown: (NSEvent *) theEvent
|
||||
{
|
||||
BOOL onKnob = NO;
|
||||
|
||||
{
|
||||
if ([parent respondsToSelector: @selector(selection)] &&
|
||||
[[parent selection] containsObject: _EO])
|
||||
{
|
||||
IBKnobPosition knob = IBNoneKnobPosition;
|
||||
NSPoint mouseDownPoint =
|
||||
[self convertPoint: [theEvent locationInWindow]
|
||||
fromView: nil];
|
||||
knob = GormKnobHitInRect([self bounds],
|
||||
mouseDownPoint);
|
||||
if (knob != IBNoneKnobPosition)
|
||||
onKnob = YES;
|
||||
}
|
||||
if (onKnob == YES)
|
||||
{
|
||||
if (parent)
|
||||
return [parent mouseDown: theEvent];
|
||||
else
|
||||
return [self noResponderFor: @selector(mouseDown:)];
|
||||
}
|
||||
}
|
||||
|
||||
if (opened == NO)
|
||||
{
|
||||
[super mouseDown: theEvent];
|
||||
return;
|
||||
}
|
||||
|
||||
if ([[_EO hitTest: [theEvent locationInWindow]]
|
||||
isDescendantOf: currentView])
|
||||
{
|
||||
NSLog(@"md %@ descendant of", self);
|
||||
if ([currentView isOpened] == NO)
|
||||
[currentView setOpened: YES];
|
||||
[currentView mouseDown: theEvent];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"md %@ not descendant of", self);
|
||||
if ([currentView isOpened] == YES)
|
||||
[currentView setOpened: NO];
|
||||
[_EO mouseDown: theEvent];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation GormTabViewEditor (TabViewDelegate)
|
||||
|
||||
- (void) tabView: (NSTabView *)tabView
|
||||
didSelectTabViewItem: (NSTabViewItem *)tabViewItem
|
||||
{
|
||||
if ([tabViewItem view])
|
||||
{
|
||||
if ([[tabViewItem view] isKindOfClass: [GormViewEditor class]] == NO)
|
||||
{
|
||||
currentView = [document editorForObject: [tabViewItem view]
|
||||
inEditor: self
|
||||
create: YES];
|
||||
NSLog(@"dSTVI %@ %@ %@", self, currentView, [tabViewItem view]);
|
||||
NSLog(@"dsTVI %@ %@", self, [document parentEditorForEditor: currentView]);
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"dsTVI %@ already there", self);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
subs = [[tabViewItem view] subviews];
|
||||
|
||||
if ([[tabViewItem view] isKindOfClass: [GormViewEditor class]] == NO)
|
||||
[document editorForObject: [tabViewItem view]
|
||||
inEditor: self
|
||||
create: YES];
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
- (BOOL) tabView: (NSTabView *)tabView
|
||||
shouldSelectTabViewItem: (NSTabViewItem *)tabViewItem
|
||||
{
|
||||
NSLog(@"shouldSelectTabViewItem called");
|
||||
|
||||
if ([[[tabView selectedTabViewItem] view]
|
||||
isKindOfClass:
|
||||
[GormInternalViewEditor class]])
|
||||
{
|
||||
|
||||
NSLog(@"closing tabviewitem");
|
||||
[(GormInternalViewEditor *)[[tabView selectedTabViewItem] view]
|
||||
deactivate];
|
||||
currentView = nil;
|
||||
openedSubeditor = nil;
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
@end
|
62
GormViewEditor.h
Normal file
62
GormViewEditor.h
Normal file
|
@ -0,0 +1,62 @@
|
|||
/* GormViewEditor.h
|
||||
*
|
||||
* Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
*
|
||||
* Author: Pierre-Yves Rivaille <pyrivail@ens-lyon.fr>
|
||||
* Date: 2002
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
@class GormViewWithSubviewsEditor;
|
||||
@class GormPlacementInfo;
|
||||
|
||||
@interface GormViewEditor : NSView <IBEditors>
|
||||
{
|
||||
id<IBDocuments> document;
|
||||
NSView *_editedObject;
|
||||
BOOL activated;
|
||||
BOOL closed;
|
||||
GormViewWithSubviewsEditor *parent;
|
||||
|
||||
}
|
||||
- (BOOL) activate;
|
||||
- (id) initWithObject: (id)anObject
|
||||
inDocument: (id<IBDocuments>)aDocument;
|
||||
- (void) close;
|
||||
- (void) deactivate;
|
||||
- (id<IBDocuments>) document;
|
||||
- (id) editedObject;
|
||||
- (void) detachSubviews;
|
||||
- (void) postDraw: (NSRect) rect;
|
||||
- (id) parent;
|
||||
@end
|
||||
|
||||
@interface GormViewEditor (EditingAdditions)
|
||||
- (NSEvent *) editTextField: view withEvent: (NSEvent *)theEvent;
|
||||
@end
|
||||
|
||||
@interface GormViewEditor (IntelligentPlacement)
|
||||
- (GormPlacementInfo *) initializeResizingInFrame: (NSView *)view
|
||||
withKnob: (IBKnobPosition) knob;
|
||||
- (void) updateResizingWithFrame: (NSRect) frame
|
||||
andEvent: (NSEvent *)theEvent
|
||||
andPlacementInfo: (GormPlacementInfo*) gpi;
|
||||
- (void) validateFrame: (NSRect) frame
|
||||
withEvent: (NSEvent *) theEvent
|
||||
andPlacementInfo: (GormPlacementInfo*)gpi;
|
||||
@end
|
1600
GormViewEditor.m
Normal file
1600
GormViewEditor.m
Normal file
File diff suppressed because it is too large
Load diff
44
GormViewWithContentViewEditor.h
Normal file
44
GormViewWithContentViewEditor.h
Normal file
|
@ -0,0 +1,44 @@
|
|||
/* GormViewWithContentViewEditor.h
|
||||
*
|
||||
* Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
*
|
||||
* Author: Pierre-Yves Rivaille <pyrivail@ens-lyon.fr>
|
||||
* Date: 2002
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
#import "GormViewWithSubviewsEditor.h"
|
||||
|
||||
@class GormInternalViewEditor;
|
||||
|
||||
@interface GormViewWithContentViewEditor : GormViewWithSubviewsEditor
|
||||
{
|
||||
GormInternalViewEditor *contentViewEditor;
|
||||
}
|
||||
|
||||
- (void) handleMouseOnKnob: (IBKnobPosition) knob
|
||||
ofView: (GormViewEditor *) view
|
||||
withEvent: (NSEvent *) theEvent;
|
||||
|
||||
- (void) handleMouseOnView: (GormViewEditor *) view
|
||||
withEvent: (NSEvent *) theEvent;
|
||||
- (void) postDrawForView: (GormViewEditor *) viewEditor;
|
||||
- (void) groupSelectionInSplitView;
|
||||
- (void) groupSelectionInBox;
|
||||
- (void) ungroup;
|
||||
- (void) pasteInView: (NSView *)view;
|
||||
@end
|
890
GormViewWithContentViewEditor.m
Normal file
890
GormViewWithContentViewEditor.m
Normal file
|
@ -0,0 +1,890 @@
|
|||
/* GormViewWithContentViewEditor.m
|
||||
*
|
||||
* Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
*
|
||||
* Author: Pierre-Yves Rivaille <pyrivail@ens-lyon.fr>
|
||||
* Date: 2002
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#import <AppKit/AppKit.h>
|
||||
|
||||
#include "GormPrivate.h"
|
||||
|
||||
#import "GormViewWithContentViewEditor.h"
|
||||
|
||||
#import "GormPlacementInfo.h"
|
||||
|
||||
#import "GormSplitViewEditor.h"
|
||||
@class GormPlacementInfo;
|
||||
|
||||
|
||||
@interface GormViewEditor (Private)
|
||||
- (NSRect) _displayMovingFrameWithHint: (NSRect) frame
|
||||
andPlacementInfo: (GormPlacementInfo *)gpi;
|
||||
@end
|
||||
|
||||
|
||||
|
||||
@implementation GormViewWithContentViewEditor
|
||||
|
||||
- (id) initWithObject: (id) anObject
|
||||
inDocument: (id<IBDocuments>)aDocument
|
||||
{
|
||||
_displaySelection = YES;
|
||||
self = [super initWithObject: anObject
|
||||
inDocument: aDocument];
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
- (void) handleMouseOnKnob: (IBKnobPosition) knob
|
||||
ofView: (GormViewEditor *) view
|
||||
withEvent: (NSEvent *) theEvent
|
||||
{
|
||||
NSPoint mouseDownPoint = [[view superview]
|
||||
convertPoint: [theEvent locationInWindow]
|
||||
fromView: nil];
|
||||
NSDate *future = [NSDate distantFuture];
|
||||
BOOL acceptsMouseMoved;
|
||||
unsigned eventMask;
|
||||
NSEvent *e;
|
||||
NSEventType eType;
|
||||
NSRect r = [view frame];
|
||||
NSPoint maxMouse;
|
||||
NSPoint minMouse;
|
||||
NSRect firstRect = [view frame];
|
||||
NSRect lastRect = [view frame];
|
||||
// NSRect constrainRect = [view frame];
|
||||
NSPoint lastPoint = mouseDownPoint;
|
||||
NSPoint point = mouseDownPoint;
|
||||
NSView *superview;
|
||||
GormPlacementInfo *gpi;
|
||||
|
||||
eventMask = NSLeftMouseUpMask | NSLeftMouseDraggedMask
|
||||
| NSMouseMovedMask | NSPeriodicMask;
|
||||
|
||||
// Save window state info.
|
||||
acceptsMouseMoved = [[self window] acceptsMouseMovedEvents];
|
||||
[[self window] setAcceptsMouseMovedEvents: YES];
|
||||
|
||||
superview = [view superview];
|
||||
[superview lockFocus];
|
||||
|
||||
_displaySelection = NO;
|
||||
|
||||
/*
|
||||
* Get size limits for resizing or moving and calculate maximum
|
||||
* and minimum mouse positions that won't cause us to exceed
|
||||
* those limits.
|
||||
*/
|
||||
{
|
||||
NSSize max = [view maximumSizeFromKnobPosition: knob];
|
||||
NSSize min = [view minimumSizeFromKnobPosition: knob];
|
||||
|
||||
r = [superview frame];
|
||||
|
||||
minMouse = NSMakePoint(NSMinX(r), NSMinY(r));
|
||||
maxMouse = NSMakePoint(NSMaxX(r), NSMaxY(r));
|
||||
r = [view frame];
|
||||
switch (knob)
|
||||
{
|
||||
case IBBottomLeftKnobPosition:
|
||||
maxMouse.x = NSMaxX(r) - min.width;
|
||||
minMouse.x = NSMaxX(r) - max.width;
|
||||
maxMouse.y = NSMaxY(r) - min.height;
|
||||
minMouse.y = NSMaxY(r) - max.height;
|
||||
break;
|
||||
|
||||
case IBMiddleLeftKnobPosition:
|
||||
maxMouse.x = NSMaxX(r) - min.width;
|
||||
minMouse.x = NSMaxX(r) - max.width;
|
||||
break;
|
||||
|
||||
case IBTopLeftKnobPosition:
|
||||
maxMouse.x = NSMaxX(r) - min.width;
|
||||
minMouse.x = NSMaxX(r) - max.width;
|
||||
maxMouse.y = NSMinY(r) + max.height;
|
||||
minMouse.y = NSMinY(r) + min.height;
|
||||
break;
|
||||
|
||||
case IBTopMiddleKnobPosition:
|
||||
maxMouse.y = NSMinY(r) + max.height;
|
||||
minMouse.y = NSMinY(r) + min.height;
|
||||
break;
|
||||
|
||||
case IBTopRightKnobPosition:
|
||||
maxMouse.x = NSMinX(r) + max.width;
|
||||
minMouse.x = NSMinX(r) + min.width;
|
||||
maxMouse.y = NSMinY(r) + max.height;
|
||||
minMouse.y = NSMinY(r) + min.height;
|
||||
break;
|
||||
|
||||
case IBMiddleRightKnobPosition:
|
||||
maxMouse.x = NSMinX(r) + max.width;
|
||||
minMouse.x = NSMinX(r) + min.width;
|
||||
break;
|
||||
|
||||
case IBBottomRightKnobPosition:
|
||||
maxMouse.x = NSMinX(r) + max.width;
|
||||
minMouse.x = NSMinX(r) + min.width;
|
||||
maxMouse.y = NSMaxY(r) - min.height;
|
||||
minMouse.y = NSMaxY(r) - max.height;
|
||||
break;
|
||||
|
||||
case IBBottomMiddleKnobPosition:
|
||||
maxMouse.y = NSMaxY(r) - min.height;
|
||||
minMouse.y = NSMaxY(r) - max.height;
|
||||
break;
|
||||
|
||||
case IBNoneKnobPosition:
|
||||
break; /* NOT REACHED */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Set the arrows cursor in case it might be something else */
|
||||
[[NSCursor arrowCursor] push];
|
||||
|
||||
/*
|
||||
* Track mouse movements until left mouse up.
|
||||
* While we keep track of all mouse movements, we only act on a
|
||||
* movement when a periodic event arives (every 20th of a second)
|
||||
* in order to avoid excessive amounts of drawing.
|
||||
*/
|
||||
[NSEvent startPeriodicEventsAfterDelay: 0.1 withPeriod: 0.05];
|
||||
e = [NSApp nextEventMatchingMask: eventMask
|
||||
untilDate: future
|
||||
inMode: NSEventTrackingRunLoopMode
|
||||
dequeue: YES];
|
||||
eType = [e type];
|
||||
|
||||
if ([view respondsToSelector: @selector(initializeResizingInFrame:withKnob:)])
|
||||
{
|
||||
gpi = [(id)view initializeResizingInFrame: superview
|
||||
withKnob: knob];
|
||||
}
|
||||
else
|
||||
{
|
||||
gpi = nil;
|
||||
}
|
||||
|
||||
while (eType != NSLeftMouseUp)
|
||||
{
|
||||
if (eType != NSPeriodic)
|
||||
{
|
||||
point = [superview convertPoint: [e locationInWindow]
|
||||
fromView: nil];
|
||||
/*
|
||||
if (edit_view != self)
|
||||
point = _constrainPointToBounds(point, [edit_view bounds]);
|
||||
*/
|
||||
}
|
||||
else if (NSEqualPoints(point, lastPoint) == NO)
|
||||
{
|
||||
[[self window] disableFlushWindow];
|
||||
|
||||
{
|
||||
float xDiff;
|
||||
float yDiff;
|
||||
|
||||
if (point.x < minMouse.x)
|
||||
point.x = minMouse.x;
|
||||
if (point.y < minMouse.y)
|
||||
point.y = minMouse.y;
|
||||
if (point.x > maxMouse.x)
|
||||
point.x = maxMouse.x;
|
||||
if (point.y > maxMouse.y)
|
||||
point.y = maxMouse.y;
|
||||
|
||||
xDiff = point.x - lastPoint.x;
|
||||
yDiff = point.y - lastPoint.y;
|
||||
lastPoint = point;
|
||||
|
||||
{
|
||||
r = GormExtBoundsForRect(r/*constrainRect*/);
|
||||
r.origin.x--;
|
||||
r.origin.y--;
|
||||
r.size.width += 2;
|
||||
r.size.height += 2;
|
||||
// [superview displayRect: r];
|
||||
r = lastRect;
|
||||
switch (knob)
|
||||
{
|
||||
case IBBottomLeftKnobPosition:
|
||||
r.origin.x += xDiff;
|
||||
r.origin.y += yDiff;
|
||||
r.size.width -= xDiff;
|
||||
r.size.height -= yDiff;
|
||||
break;
|
||||
|
||||
case IBMiddleLeftKnobPosition:
|
||||
r.origin.x += xDiff;
|
||||
r.size.width -= xDiff;
|
||||
break;
|
||||
|
||||
case IBTopLeftKnobPosition:
|
||||
r.origin.x += xDiff;
|
||||
r.size.width -= xDiff;
|
||||
r.size.height += yDiff;
|
||||
break;
|
||||
|
||||
case IBTopMiddleKnobPosition:
|
||||
r.size.height += yDiff;
|
||||
break;
|
||||
|
||||
case IBTopRightKnobPosition:
|
||||
r.size.width += xDiff;
|
||||
r.size.height += yDiff;
|
||||
break;
|
||||
|
||||
case IBMiddleRightKnobPosition:
|
||||
r.size.width += xDiff;
|
||||
break;
|
||||
|
||||
case IBBottomRightKnobPosition:
|
||||
r.origin.y += yDiff;
|
||||
r.size.width += xDiff;
|
||||
r.size.height -= yDiff;
|
||||
break;
|
||||
|
||||
case IBBottomMiddleKnobPosition:
|
||||
r.origin.y += yDiff;
|
||||
r.size.height -= yDiff;
|
||||
break;
|
||||
|
||||
case IBNoneKnobPosition:
|
||||
break; /* NOT REACHED */
|
||||
}
|
||||
|
||||
lastRect = r;
|
||||
|
||||
if ([view respondsToSelector:
|
||||
@selector(updateResizingWithFrame:andEvent:andPlacementInfo:)])
|
||||
{
|
||||
[view updateResizingWithFrame: r
|
||||
andEvent: theEvent
|
||||
andPlacementInfo: gpi];
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* Flush any drawing performed for this event.
|
||||
*/
|
||||
[[self window] enableFlushWindow];
|
||||
[[self window] flushWindow];
|
||||
}
|
||||
}
|
||||
|
||||
e = [NSApp nextEventMatchingMask: eventMask
|
||||
untilDate: future
|
||||
inMode: NSEventTrackingRunLoopMode
|
||||
dequeue: YES];
|
||||
eType = [e type];
|
||||
}
|
||||
|
||||
[NSEvent stopPeriodicEvents];
|
||||
[NSCursor pop];
|
||||
/* Typically after a view has been dragged in a window, NSWindow
|
||||
sends a spurious moustEntered event. Sending the mouseUp
|
||||
event back to the NSWindow resets the NSWindow's idea of the
|
||||
last mouse point so it doesn't think that the mouse has
|
||||
entered the view (since it was always there, it's just that
|
||||
the view moved). */
|
||||
[[self window] postEvent: e atStart: NO];
|
||||
|
||||
{
|
||||
NSRect redrawRect;
|
||||
|
||||
/*
|
||||
* This was a subview resize, so we must clean up by removing
|
||||
* the highlighted knob and the wireframe around the view.
|
||||
*/
|
||||
|
||||
[view updateResizingWithFrame: r
|
||||
andEvent: theEvent
|
||||
andPlacementInfo: gpi];
|
||||
|
||||
[view validateFrame: r
|
||||
withEvent: theEvent
|
||||
andPlacementInfo: gpi];
|
||||
|
||||
r = GormExtBoundsForRect(lastRect);
|
||||
r.origin.x--;
|
||||
r.origin.y--;
|
||||
r.size.width += 2;
|
||||
r.size.height += 2;
|
||||
/*
|
||||
* If this was a simple resize, we must redraw the union of
|
||||
* the original frame, and the final frame, and the area
|
||||
* where we were drawing the wireframe and handles.
|
||||
*/
|
||||
redrawRect = NSUnionRect(r, redrawRect);
|
||||
redrawRect = NSUnionRect(firstRect, redrawRect);
|
||||
// [superview displayRect: redrawRect];
|
||||
// [self makeSelectionVisible: YES];
|
||||
}
|
||||
|
||||
|
||||
if (NSEqualPoints(point, mouseDownPoint) == NO)
|
||||
{
|
||||
/*
|
||||
* A subview was moved or resized, so we must mark the
|
||||
* doucment as edited.
|
||||
*/
|
||||
[document touch];
|
||||
}
|
||||
|
||||
[superview unlockFocus];
|
||||
_displaySelection = YES;
|
||||
|
||||
[self setNeedsDisplay: YES];
|
||||
/*
|
||||
* Restore state to what it was on entry.
|
||||
*/
|
||||
[[self window] setAcceptsMouseMovedEvents: acceptsMouseMoved];
|
||||
|
||||
}
|
||||
|
||||
- (void) handleMouseOnView: (GormViewEditor *) view
|
||||
withEvent: (NSEvent *) theEvent
|
||||
{
|
||||
NSPoint mouseDownPoint = [[view superview]
|
||||
convertPoint: [theEvent locationInWindow]
|
||||
fromView: nil];
|
||||
NSDate *future = [NSDate distantFuture];
|
||||
NSView *subview;
|
||||
BOOL acceptsMouseMoved;
|
||||
BOOL dragStarted = NO;
|
||||
unsigned eventMask;
|
||||
NSEvent *e;
|
||||
NSEventType eType;
|
||||
NSRect r;
|
||||
NSPoint maxMouse;
|
||||
NSPoint minMouse;
|
||||
NSPoint lastPoint = mouseDownPoint;
|
||||
NSPoint point = mouseDownPoint;
|
||||
NSView *superview;
|
||||
NSEnumerator *enumerator;
|
||||
NSRect oldMovingFrame;
|
||||
NSRect suggestedFrame;
|
||||
GormPlacementInfo *gpi;
|
||||
|
||||
// NSLog(@"hMOV %@", self);
|
||||
|
||||
eventMask = NSLeftMouseUpMask | NSLeftMouseDraggedMask
|
||||
| NSMouseMovedMask | NSPeriodicMask;
|
||||
|
||||
// Save window state info.
|
||||
acceptsMouseMoved = [[self window] acceptsMouseMovedEvents];
|
||||
[[self window] setAcceptsMouseMovedEvents: YES];
|
||||
|
||||
if (view == nil)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ([theEvent modifierFlags] & NSShiftKeyMask)
|
||||
{
|
||||
if ([selection containsObject: view])
|
||||
{
|
||||
NSMutableArray *newSelection = [selection mutableCopy];
|
||||
[newSelection removeObjectIdenticalTo: view];
|
||||
[self selectObjects: newSelection];
|
||||
RELEASE(newSelection);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
NSArray *newSelection;
|
||||
newSelection = [selection arrayByAddingObject: view];
|
||||
[self selectObjects: newSelection];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
[self selectObjects: [NSArray arrayWithObject: view]];
|
||||
}
|
||||
|
||||
superview = [view superview];
|
||||
[superview lockFocus];
|
||||
|
||||
{
|
||||
NSRect vf = [view frame];
|
||||
NSRect sf = [superview bounds];
|
||||
NSPoint tr = NSMakePoint(NSMaxX(vf), NSMaxY(vf));
|
||||
NSPoint bl = NSMakePoint(NSMinX(vf), NSMinY(vf));
|
||||
|
||||
enumerator = [selection objectEnumerator];
|
||||
while ((subview = [enumerator nextObject]) != nil)
|
||||
{
|
||||
if (subview != view)
|
||||
{
|
||||
float tmp;
|
||||
|
||||
vf = [subview frame];
|
||||
tmp = NSMaxX(vf);
|
||||
if (tmp > tr.x)
|
||||
tr.x = tmp;
|
||||
tmp = NSMaxY(vf);
|
||||
if (tmp > tr.y)
|
||||
tr.y = tmp;
|
||||
tmp = NSMinX(vf);
|
||||
if (tmp < bl.x)
|
||||
bl.x = tmp;
|
||||
tmp = NSMinY(vf);
|
||||
if (tmp < bl.y)
|
||||
bl.y = tmp;
|
||||
}
|
||||
}
|
||||
minMouse.x = point.x - bl.x;
|
||||
minMouse.y = point.y - bl.y;
|
||||
maxMouse.x = NSMaxX(sf) - tr.x + point.x;
|
||||
maxMouse.y = NSMaxY(sf) - tr.y + point.y;
|
||||
}
|
||||
|
||||
if ([selection count] == 1)
|
||||
{
|
||||
oldMovingFrame = [[selection objectAtIndex: 0] frame];
|
||||
gpi = [[selection objectAtIndex: 0] initializeResizingInFrame:
|
||||
[self superview]
|
||||
withKnob: IBNoneKnobPosition];
|
||||
suggestedFrame = oldMovingFrame;
|
||||
}
|
||||
|
||||
/* Set the arrows cursor in case it might be something else */
|
||||
[[NSCursor arrowCursor] push];
|
||||
|
||||
/*
|
||||
* Track mouse movements until left mouse up.
|
||||
* While we keep track of all mouse movements, we only act on a
|
||||
* movement when a periodic event arives (every 20th of a second)
|
||||
* in order to avoid excessive amounts of drawing.
|
||||
*/
|
||||
[NSEvent startPeriodicEventsAfterDelay: 0.1 withPeriod: 0.05];
|
||||
e = [NSApp nextEventMatchingMask: eventMask
|
||||
untilDate: future
|
||||
inMode: NSEventTrackingRunLoopMode
|
||||
dequeue: YES];
|
||||
|
||||
eType = [e type];
|
||||
while (eType != NSLeftMouseUp)
|
||||
{
|
||||
if (eType != NSPeriodic)
|
||||
{
|
||||
point = [superview convertPoint: [e locationInWindow]
|
||||
fromView: nil];
|
||||
/*
|
||||
point = _constrainPointToBounds(point, [superview bounds]);
|
||||
*/
|
||||
}
|
||||
else if (NSEqualPoints(point, lastPoint) == NO)
|
||||
{
|
||||
[[self window] disableFlushWindow];
|
||||
|
||||
{
|
||||
float xDiff;
|
||||
float yDiff;
|
||||
|
||||
if (point.x < minMouse.x)
|
||||
point.x = minMouse.x;
|
||||
if (point.y < minMouse.y)
|
||||
point.y = minMouse.y;
|
||||
if (point.x > maxMouse.x)
|
||||
point.x = maxMouse.x;
|
||||
if (point.y > maxMouse.y)
|
||||
point.y = maxMouse.y;
|
||||
|
||||
xDiff = point.x - lastPoint.x;
|
||||
yDiff = point.y - lastPoint.y;
|
||||
lastPoint = point;
|
||||
|
||||
if (dragStarted == NO)
|
||||
{
|
||||
/*
|
||||
* Remove selection knobs before moving selection.
|
||||
*/
|
||||
dragStarted = YES;
|
||||
_displaySelection = NO;
|
||||
[self setNeedsDisplay: YES];
|
||||
}
|
||||
|
||||
if ([selection count] == 1)
|
||||
{
|
||||
{
|
||||
NSRect tempFrame = [[selection objectAtIndex: 0] frame];
|
||||
[[selection objectAtIndex: 0]
|
||||
setFrameOrigin:
|
||||
NSMakePoint(NSMaxX([self bounds]),
|
||||
NSMaxY([self bounds]))];
|
||||
[superview display];
|
||||
[[selection objectAtIndex: 0]
|
||||
setFrameOrigin: tempFrame.origin];
|
||||
}
|
||||
r = oldMovingFrame;
|
||||
r.origin.x += xDiff;
|
||||
r.origin.y += yDiff;
|
||||
r.origin.x = (int) r.origin.x;
|
||||
r.origin.y = (int) r.origin.y;
|
||||
r.size.width = (int) r.size.width;
|
||||
r.size.height = (int) r.size.height;
|
||||
oldMovingFrame = r;
|
||||
suggestedFrame = [[selection objectAtIndex: 0]
|
||||
_displayMovingFrameWithHint: r
|
||||
andPlacementInfo: gpi];
|
||||
[[selection objectAtIndex: 0] setFrame:
|
||||
suggestedFrame];
|
||||
[[selection objectAtIndex: 0] setNeedsDisplay: YES];
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
enumerator = [selection objectEnumerator];
|
||||
|
||||
while ((subview = [enumerator nextObject]) != nil)
|
||||
{
|
||||
NSRect oldFrame = [subview frame];
|
||||
|
||||
r = oldFrame;
|
||||
r.origin.x += xDiff;
|
||||
r.origin.y += yDiff;
|
||||
r.origin.x = (int) r.origin.x;
|
||||
r.origin.y = (int) r.origin.y;
|
||||
r.size.width = (int) r.size.width;
|
||||
r.size.height = (int) r.size.height;
|
||||
[subview setFrame: r];
|
||||
[superview setNeedsDisplayInRect: oldFrame];
|
||||
[subview setNeedsDisplay: YES];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Flush any drawing performed for this event.
|
||||
*/
|
||||
[[self window] displayIfNeeded];
|
||||
[[self window] enableFlushWindow];
|
||||
[[self window] flushWindow];
|
||||
}
|
||||
}
|
||||
e = [NSApp nextEventMatchingMask: eventMask
|
||||
untilDate: future
|
||||
inMode: NSEventTrackingRunLoopMode
|
||||
dequeue: YES];
|
||||
eType = [e type];
|
||||
}
|
||||
|
||||
_displaySelection = YES;
|
||||
|
||||
if ([selection count] == 1)
|
||||
[[selection objectAtIndex: 0] setFrame: suggestedFrame];
|
||||
[self setNeedsDisplay: YES];
|
||||
[NSEvent stopPeriodicEvents];
|
||||
[NSCursor pop];
|
||||
/* Typically after a view has been dragged in a window, NSWindow
|
||||
sends a spurious moustEntered event. Sending the mouseUp
|
||||
event back to the NSWindow resets the NSWindow's idea of the
|
||||
last mouse point so it doesn't think that the mouse has
|
||||
entered the view (since it was always there, it's just that
|
||||
the view moved). */
|
||||
[[self window] postEvent: e atStart: NO];
|
||||
|
||||
|
||||
if (NSEqualPoints(point, mouseDownPoint) == NO)
|
||||
{
|
||||
/*
|
||||
* A subview was moved or resized, so we must mark the
|
||||
* doucment as edited.
|
||||
*/
|
||||
[document touch];
|
||||
}
|
||||
|
||||
[superview unlockFocus];
|
||||
/*
|
||||
* Restore state to what it was on entry.
|
||||
*/
|
||||
[[self window] setAcceptsMouseMovedEvents: acceptsMouseMoved];
|
||||
|
||||
}
|
||||
|
||||
- (BOOL) acceptsTypeFromArray: (NSArray*)types
|
||||
{
|
||||
if ([super acceptsTypeFromArray: types])
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
else
|
||||
{
|
||||
return [types containsObject: IBViewPboardType];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) postDrawForView: (GormViewEditor *) viewEditor
|
||||
{
|
||||
if (_displaySelection == NO)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (((id)openedSubeditor == (id)viewEditor)
|
||||
&& (openedSubeditor != nil)
|
||||
&& ![openedSubeditor isKindOfClass: [GormInternalViewEditor class]])
|
||||
{
|
||||
GormDrawOpenKnobsForRect([viewEditor bounds]);
|
||||
GormShowFastKnobFills();
|
||||
}
|
||||
else if ([selection containsObject: viewEditor])
|
||||
{
|
||||
GormDrawKnobsForRect([viewEditor bounds]);
|
||||
GormShowFastKnobFills();
|
||||
}
|
||||
}
|
||||
|
||||
- (void) postDraw: (NSRect) rect
|
||||
{
|
||||
[super postDraw: rect];
|
||||
|
||||
if (openedSubeditor
|
||||
&& ![openedSubeditor isKindOfClass: [GormInternalViewEditor class]])
|
||||
{
|
||||
GormDrawOpenKnobsForRect(
|
||||
[self convertRect: [openedSubeditor bounds]
|
||||
fromView: openedSubeditor]);
|
||||
GormShowFastKnobFills();
|
||||
}
|
||||
else if (_displaySelection)
|
||||
{
|
||||
int i;
|
||||
int count = [selection count];
|
||||
|
||||
for ( i = 0; i < count ; i++ )
|
||||
{
|
||||
GormDrawKnobsForRect([self convertRect:
|
||||
[[selection objectAtIndex: i] bounds]
|
||||
fromView: [selection objectAtIndex: i]]);
|
||||
GormShowFastKnobFills();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#undef MAX
|
||||
#undef MIN
|
||||
|
||||
#define MAX(A,B) ((A)>(B)?(A):(B))
|
||||
#define MIN(A,B) ((A)<(B)?(A):(B))
|
||||
|
||||
- (void) groupSelectionInSplitView
|
||||
{
|
||||
NSEnumerator *enumerator;
|
||||
GormViewEditor *subview;
|
||||
NSSplitView *splitView;
|
||||
NSRect rect = NSZeroRect;
|
||||
GormViewEditor *editor;
|
||||
NSView *superview;
|
||||
|
||||
if ([selection count] < 2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
enumerator = [selection objectEnumerator];
|
||||
|
||||
while ((subview = [enumerator nextObject]) != nil)
|
||||
{
|
||||
superview = [subview superview];
|
||||
rect = NSUnionRect(rect, [subview frame]);
|
||||
[subview deactivate];
|
||||
}
|
||||
|
||||
splitView = [[NSSplitView alloc] initWithFrame: rect];
|
||||
|
||||
|
||||
[document attachObject: splitView
|
||||
toParent: _editedObject];
|
||||
|
||||
[superview addSubview: splitView];
|
||||
|
||||
|
||||
enumerator = [selection objectEnumerator];
|
||||
|
||||
editor = [document editorForObject: splitView
|
||||
inEditor: self
|
||||
create: YES];
|
||||
|
||||
while ((subview = [enumerator nextObject]) != nil)
|
||||
{
|
||||
id eO = [subview editedObject];
|
||||
[splitView addSubview: [subview editedObject]];
|
||||
[document attachObject: [subview editedObject]
|
||||
toParent: splitView];
|
||||
[subview close];
|
||||
[document editorForObject: eO
|
||||
inEditor: editor
|
||||
create: YES];
|
||||
}
|
||||
|
||||
[self selectObjects: [NSArray arrayWithObject: editor]];
|
||||
}
|
||||
|
||||
- (void) groupSelectionInBox
|
||||
{
|
||||
NSEnumerator *enumerator;
|
||||
GormViewEditor *subview;
|
||||
NSBox *box;
|
||||
NSRect rect = NSZeroRect;
|
||||
GormViewEditor *editor;
|
||||
NSView *superview;
|
||||
|
||||
if ([selection count] < 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
enumerator = [selection objectEnumerator];
|
||||
|
||||
while ((subview = [enumerator nextObject]) != nil)
|
||||
{
|
||||
superview = [subview superview];
|
||||
rect = NSUnionRect(rect, [subview frame]);
|
||||
[subview deactivate];
|
||||
}
|
||||
|
||||
box = [[NSBox alloc] initWithFrame: NSZeroRect];
|
||||
[box setFrameFromContentFrame: rect];
|
||||
|
||||
[document attachObject: box
|
||||
toParent: _editedObject];
|
||||
|
||||
[superview addSubview: box];
|
||||
|
||||
|
||||
enumerator = [selection objectEnumerator];
|
||||
|
||||
while ((subview = [enumerator nextObject]) != nil)
|
||||
{
|
||||
NSPoint frameOrigin;
|
||||
[box addSubview: [subview editedObject]];
|
||||
frameOrigin = [[subview editedObject] frame].origin;
|
||||
frameOrigin.x -= rect.origin.x;
|
||||
frameOrigin.y -= rect.origin.y;
|
||||
[[subview editedObject] setFrameOrigin: frameOrigin];
|
||||
[subview close];
|
||||
}
|
||||
|
||||
editor = [document editorForObject: box
|
||||
inEditor: self
|
||||
create: YES];
|
||||
|
||||
[self selectObjects: [NSArray arrayWithObject: editor]];
|
||||
}
|
||||
|
||||
|
||||
@class GormBoxEditor;
|
||||
@class GormSplitViewEditor;
|
||||
|
||||
- (void) ungroup
|
||||
{
|
||||
NSView *toUngroup;
|
||||
|
||||
if ([selection count] != 1)
|
||||
return;
|
||||
|
||||
NSLog(@"ungroup called");
|
||||
|
||||
toUngroup = [selection objectAtIndex: 0];
|
||||
|
||||
|
||||
if ([toUngroup isKindOfClass: [GormBoxEditor class]]
|
||||
|| [toUngroup isKindOfClass: [GormSplitViewEditor class]])
|
||||
{
|
||||
id contentView = toUngroup;
|
||||
|
||||
NSMutableArray *newSelection = [NSMutableArray array];
|
||||
NSArray *views;
|
||||
int i;
|
||||
views = [contentView destroyAndListSubviews];
|
||||
for (i = 0; i < [views count]; i++)
|
||||
{
|
||||
[_editedObject addSubview: [views objectAtIndex: i]];
|
||||
[newSelection addObject:
|
||||
[document editorForObject: [views objectAtIndex: i]
|
||||
inEditor: self
|
||||
create: YES]];
|
||||
}
|
||||
[self selectObjects: newSelection];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
- (void) pasteInView: (NSView *)view
|
||||
{
|
||||
NSPasteboard *pb = [NSPasteboard generalPasteboard];
|
||||
NSMutableArray *array = [NSMutableArray array];
|
||||
NSArray *views;
|
||||
NSEnumerator *enumerator;
|
||||
NSView *sub;
|
||||
/*
|
||||
NSView *subs = [view subviews];
|
||||
int i;
|
||||
int count;
|
||||
BOOL alreadyThere = YES;
|
||||
*/
|
||||
|
||||
/*
|
||||
* Ask the document to get the copied views from the pasteboard and add
|
||||
* them to it's collection of known objects.
|
||||
*/
|
||||
views = [document pasteType: IBViewPboardType
|
||||
fromPasteboard: pb
|
||||
parent: _editedObject];
|
||||
/*
|
||||
* Now make all the views subviews of ourself.
|
||||
*/
|
||||
enumerator = [views objectEnumerator];
|
||||
while ((sub = [enumerator nextObject]) != nil)
|
||||
{
|
||||
if ([sub isKindOfClass: [NSView class]] == YES)
|
||||
{
|
||||
/*
|
||||
for( i = 0; i < count; i++ )
|
||||
{
|
||||
if (NSEqualRects([sub frame],
|
||||
[[subs objectAtIndex: i] frame]))
|
||||
break;
|
||||
}
|
||||
if (i >= count)
|
||||
alreadyThere = NO;
|
||||
*/
|
||||
[view addSubview: sub];
|
||||
[array addObject:
|
||||
[document editorForObject: sub
|
||||
inEditor: self
|
||||
create: YES]];
|
||||
}
|
||||
}
|
||||
// [self makeSelectionVisible: NO];
|
||||
[self selectObjects: array];
|
||||
// [self makeSelectionVisible: YES];
|
||||
}
|
||||
|
||||
@end
|
53
GormViewWithSubviewsEditor.h
Normal file
53
GormViewWithSubviewsEditor.h
Normal file
|
@ -0,0 +1,53 @@
|
|||
/* GormViewWithSubviewsEditor.h
|
||||
*
|
||||
* Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
*
|
||||
* Author: Pierre-Yves Rivaille <pyrivail@ens-lyon.fr>
|
||||
* Date: 2002
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#import "GormViewEditor.h"
|
||||
|
||||
@interface GormViewWithSubviewsEditor : GormViewEditor <IBSelectionOwners>
|
||||
{
|
||||
BOOL _displaySelection;
|
||||
BOOL opened;
|
||||
GormViewWithSubviewsEditor *openedSubeditor;
|
||||
NSMutableArray *selection;
|
||||
}
|
||||
|
||||
- (BOOL) isOpened;
|
||||
- (BOOL) canBeOpened;
|
||||
- (void) setOpenedSubeditor: (GormViewWithSubviewsEditor *) newEditor;
|
||||
- (void) setOpened: (BOOL) value;
|
||||
- (void) openParentEditor;
|
||||
- (void) makeSubeditorResign;
|
||||
- (void) silentlyResetSelection;
|
||||
- (void) makeSelectionVisible: (BOOL) value;
|
||||
- (NSArray*) selection;
|
||||
- (void) selectObjects: (NSArray *) objects;
|
||||
- (void) copySelection;
|
||||
- (void) deleteSelection;
|
||||
|
||||
/*
|
||||
* Close subeditors of this editor.
|
||||
*/
|
||||
- (void) closeSubeditors;
|
||||
- (void) deactivateSubeditors;
|
||||
@end
|
277
GormViewWithSubviewsEditor.m
Normal file
277
GormViewWithSubviewsEditor.m
Normal file
|
@ -0,0 +1,277 @@
|
|||
/* GormViewWithSubviewsEditor.m
|
||||
*
|
||||
* Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
*
|
||||
* Author: Pierre-Yves Rivaille <pyrivail@ens-lyon.fr>
|
||||
* Date: 2002
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#import <AppKit/AppKit.h>
|
||||
|
||||
#include "GormPrivate.h"
|
||||
|
||||
#import "GormViewWithSubviewsEditor.h"
|
||||
|
||||
@class GormEditorToParent;
|
||||
|
||||
@implementation GormViewWithSubviewsEditor
|
||||
|
||||
- (void) close
|
||||
{
|
||||
if (closed == NO)
|
||||
{
|
||||
// NSLog(@"%@ close", self);
|
||||
[self deactivate];
|
||||
|
||||
[self closeSubeditors];
|
||||
[document editor: self didCloseForObject: _editedObject];
|
||||
closed = YES;
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"%@ close but already closed", self);
|
||||
}
|
||||
}
|
||||
|
||||
- (void) deactivateSubeditors
|
||||
{
|
||||
NSArray *subeditorConnections =
|
||||
[NSArray arrayWithArray: [document connectorsForDestination: self
|
||||
ofClass: [GormEditorToParent class]]];
|
||||
|
||||
int count = [subeditorConnections count];
|
||||
int i;
|
||||
|
||||
// NSLog(@"start deactivating subeditors");
|
||||
for ( i = 0; i < count; i ++ )
|
||||
{
|
||||
// NSLog(@"%@", [[subeditorConnections objectAtIndex: i] source]);
|
||||
[[[subeditorConnections objectAtIndex: i] source] deactivate];
|
||||
}
|
||||
// NSLog(@"end deactivating subeditors");
|
||||
}
|
||||
|
||||
- (void) closeSubeditors
|
||||
{
|
||||
NSArray *subeditorConnections =
|
||||
[NSArray arrayWithArray: [document connectorsForDestination: self
|
||||
ofClass: [GormEditorToParent class]]];
|
||||
|
||||
int count = [subeditorConnections count];
|
||||
int i;
|
||||
|
||||
// NSLog(@"start subeditor's list");
|
||||
for ( i = 0; i < count; i ++ )
|
||||
{
|
||||
// NSLog(@"%@", [[subeditorConnections objectAtIndex: i] source]);
|
||||
[[[subeditorConnections objectAtIndex: i] source] close];
|
||||
}
|
||||
// NSLog(@"end subeditor's list");
|
||||
}
|
||||
|
||||
|
||||
- (BOOL) canBeOpened
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL) isOpened
|
||||
{
|
||||
return opened;
|
||||
}
|
||||
|
||||
|
||||
- (void) setOpened: (BOOL) value
|
||||
{
|
||||
opened = value;
|
||||
|
||||
if (value == YES)
|
||||
{
|
||||
// NSLog(@"sO %@ we are opened", self);
|
||||
[self silentlyResetSelection];
|
||||
[document setSelectionFromEditor: self];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (openedSubeditor != nil)
|
||||
{
|
||||
// NSLog(@"let's closed our subeditor");
|
||||
[self makeSubeditorResign];
|
||||
[self silentlyResetSelection];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self silentlyResetSelection];
|
||||
}
|
||||
[self setNeedsDisplay: YES];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
- (void) openParentEditor
|
||||
{
|
||||
if ([parent respondsToSelector: @selector(setOpenedSubeditor:)])
|
||||
{
|
||||
[parent setOpenedSubeditor: self];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) setOpenedSubeditor: (GormViewWithSubviewsEditor *) newEditor
|
||||
{
|
||||
[self silentlyResetSelection];
|
||||
|
||||
if (opened == NO)
|
||||
{
|
||||
[self openParentEditor];
|
||||
}
|
||||
|
||||
opened = YES;
|
||||
|
||||
if (newEditor != openedSubeditor)
|
||||
{
|
||||
[self makeSubeditorResign];
|
||||
}
|
||||
|
||||
openedSubeditor = newEditor;
|
||||
|
||||
[self setNeedsDisplay: YES];
|
||||
}
|
||||
|
||||
/*
|
||||
* take the selection from the subeditors
|
||||
*/
|
||||
- (void) makeSubeditorResign
|
||||
{
|
||||
if (openedSubeditor != nil)
|
||||
{
|
||||
// NSLog(@"%@ makeSubeditorResign", self);
|
||||
[openedSubeditor makeSubeditorResign];
|
||||
[openedSubeditor setOpened: NO];
|
||||
openedSubeditor = nil;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (void) makeSelectionVisible: (BOOL) value
|
||||
{
|
||||
}
|
||||
|
||||
- (void) changeFont: (id)sender
|
||||
{
|
||||
NSEnumerator *enumerator = [[self selection] objectEnumerator];
|
||||
id anObject;
|
||||
NSFont *newFont;
|
||||
|
||||
while ((anObject = [enumerator nextObject]))
|
||||
{
|
||||
if ([anObject respondsToSelector: @selector(font)]
|
||||
&& [anObject respondsToSelector: @selector(setFont:)])
|
||||
{
|
||||
newFont = [sender convertFont: [anObject font]];
|
||||
[anObject setFont: newFont];
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
- (NSArray*) selection
|
||||
{
|
||||
int i;
|
||||
int count = [selection count];
|
||||
NSMutableArray *result = [NSMutableArray arrayWithCapacity: count];
|
||||
|
||||
if (count != 0)
|
||||
{
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
if ([[selection objectAtIndex: i]
|
||||
respondsToSelector: @selector(editedObject)])
|
||||
[result addObject: [[selection objectAtIndex: i] editedObject]];
|
||||
else
|
||||
[result addObject: [selection objectAtIndex: i]];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ([self respondsToSelector: @selector(editedObject)])
|
||||
[result addObject: [self editedObject]];
|
||||
else
|
||||
[result addObject: self];
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
- (void) selectObjects: (NSArray *) objects
|
||||
{
|
||||
int i;
|
||||
int count = [objects count];
|
||||
TEST_RELEASE(selection);
|
||||
|
||||
selection = [[NSMutableArray alloc] initWithCapacity: [objects count]];
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
// NSLog(@"adding %@", [objects objectAtIndex: i]);
|
||||
[selection addObject: [objects objectAtIndex: i]];
|
||||
}
|
||||
|
||||
[self makeSubeditorResign];
|
||||
|
||||
opened = YES;
|
||||
|
||||
[self openParentEditor];
|
||||
|
||||
[document setSelectionFromEditor: self];
|
||||
|
||||
[self setNeedsDisplay: YES];
|
||||
}
|
||||
|
||||
- (void) silentlyResetSelection
|
||||
{
|
||||
TEST_RELEASE(selection);
|
||||
|
||||
selection = [[NSMutableArray alloc] initWithCapacity: 5];
|
||||
|
||||
}
|
||||
|
||||
- (void) copySelection
|
||||
{
|
||||
if ([selection count] > 0)
|
||||
{
|
||||
[document copyObjects: [self selection]
|
||||
type: IBViewPboardType
|
||||
toPasteboard: [NSPasteboard generalPasteboard]];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) deleteSelection
|
||||
{
|
||||
NSLog(@"deleteSelection should be subclassed");
|
||||
}
|
||||
|
||||
- (BOOL) acceptsFirstResponder
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
3123
GormWindowEditor.m
3123
GormWindowEditor.m
File diff suppressed because it is too large
Load diff
|
@ -50,7 +50,7 @@
|
|||
|
||||
|
||||
|
||||
@interface GormMenuEditor : NSMenuView <IBEditors>
|
||||
@interface GormMenuEditor : NSMenuView <IBEditors, IBSelectionOwners>
|
||||
{
|
||||
id<IBDocuments> document;
|
||||
NSMenu *edited;
|
||||
|
@ -310,7 +310,7 @@
|
|||
* handle it - but make sure the menu is selected in the editor first.
|
||||
*/
|
||||
[[document parentEditorForEditor: self] selectObjects:
|
||||
[NSArray arrayWithObject: edited]];
|
||||
[NSArray arrayWithObject: edited]];
|
||||
[hit mouseDown: theEvent];
|
||||
}
|
||||
}
|
||||
|
@ -784,12 +784,6 @@ NSLog(@"Link at index: %d (%@)", pos, NSStringFromPoint(loc));
|
|||
[[self window] makeKeyAndOrderFront: self];
|
||||
}
|
||||
|
||||
- (id) selectAll: (id)sender
|
||||
{
|
||||
[self selectObjects: [edited itemArray]];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) selectObjects: (NSArray*)anArray
|
||||
{
|
||||
if ([anArray isEqual: selection] == NO)
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
@implementation GormWindowMaker
|
||||
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
[super encodeWithCoder: aCoder];
|
||||
}
|
||||
- (id) initWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -50,21 +50,21 @@
|
|||
/*******************/
|
||||
|
||||
// Editable text field
|
||||
v = [[NSTextField alloc] initWithFrame: NSMakeRect(10, 127, 56, 21)];
|
||||
v = [[NSTextField alloc] initWithFrame: NSMakeRect(10, 147, 56, 21)];
|
||||
[v setEditable: YES];
|
||||
[v setStringValue: @"Text"];
|
||||
[contents addSubview: v];
|
||||
RELEASE(v);
|
||||
|
||||
// Push button
|
||||
v = [[NSButton alloc] initWithFrame: NSMakeRect(10, 90, 56, 24)];
|
||||
[v setButtonType: NSToggleButton];
|
||||
v = [[NSButton alloc] initWithFrame: NSMakeRect(10, 110, 56, 24)];
|
||||
[v setButtonType: NSMomentaryPushButton];
|
||||
[v setTitle: @"Button"];
|
||||
[contents addSubview: v];
|
||||
RELEASE(v);
|
||||
|
||||
// Checkbox
|
||||
v = [[NSButton alloc] initWithFrame: NSMakeRect(10, 60, 56, 16)];
|
||||
v = [[NSButton alloc] initWithFrame: NSMakeRect(10, 80, 56, 16)];
|
||||
[v setButtonType: NSSwitchButton];
|
||||
[v setImagePosition: NSImageRight];
|
||||
[v setTitle: @"Switch"];
|
||||
|
@ -73,7 +73,7 @@
|
|||
RELEASE(v);
|
||||
|
||||
// Radio button: default on
|
||||
v = [[NSButton alloc] initWithFrame: NSMakeRect(10, 35, 56, 15)];
|
||||
v = [[NSButton alloc] initWithFrame: NSMakeRect(10, 55, 56, 16)];
|
||||
[v setButtonType: NSRadioButton];
|
||||
[v setImagePosition: NSImageLeft];
|
||||
[v setTitle: @"Radio"];
|
||||
|
@ -83,7 +83,7 @@
|
|||
RELEASE(v);
|
||||
|
||||
// Radio button: default off
|
||||
v = [[NSButton alloc] initWithFrame: NSMakeRect(10, 17, 56, 15)];
|
||||
v = [[NSButton alloc] initWithFrame: NSMakeRect(10, 37, 56, 16)];
|
||||
[v setButtonType: NSRadioButton];
|
||||
[v setImagePosition: NSImageLeft];
|
||||
[v setTitle: @"Radio"];
|
||||
|
@ -98,7 +98,7 @@
|
|||
/********************/
|
||||
|
||||
// Non editable text field (label)
|
||||
v = [[NSTextField alloc] initWithFrame: NSMakeRect(78, 132, 83, 14)];
|
||||
v = [[NSTextField alloc] initWithFrame: NSMakeRect(78, 152, 83, 18)];
|
||||
[v setEditable: NO];
|
||||
[v setSelectable: NO];
|
||||
[v setBezeled: NO];
|
||||
|
@ -110,35 +110,44 @@
|
|||
RELEASE(v);
|
||||
|
||||
// Group box
|
||||
v = [[NSBox alloc] initWithFrame: NSMakeRect(78, 78, 53, 44)];
|
||||
v = [[NSBox alloc] initWithFrame: NSMakeRect(78, 98, 53, 44)];
|
||||
[v setTitle: @"Box"];
|
||||
[contents addSubview: v];
|
||||
RELEASE(v);
|
||||
|
||||
// Color well
|
||||
v = [[NSColorWell alloc] initWithFrame: NSMakeRect(78, 42, 53, 30)];
|
||||
v = [[NSColorWell alloc] initWithFrame: NSMakeRect(78, 62, 53, 30)];
|
||||
[contents addSubview: v];
|
||||
RELEASE(v);
|
||||
|
||||
// Horizontal Slider
|
||||
v = [[NSSlider alloc] initWithFrame: NSMakeRect(78, 19, 83, 16)];
|
||||
v = [[NSSlider alloc] initWithFrame: NSMakeRect(78, 39, 83, 16)];
|
||||
[v setDoubleValue: 0];
|
||||
[v setContinuous: YES];
|
||||
[contents addSubview: v];
|
||||
RELEASE(v);
|
||||
|
||||
// Vertical Slider
|
||||
v = [[NSSlider alloc] initWithFrame: NSMakeRect(145, 42, 16, 76)];
|
||||
v = [[NSSlider alloc] initWithFrame: NSMakeRect(145, 62, 16, 76)];
|
||||
[v setDoubleValue: 0];
|
||||
[v setContinuous: YES];
|
||||
[contents addSubview: v];
|
||||
RELEASE(v);
|
||||
|
||||
// Progress Indicator
|
||||
v = [[NSProgressIndicator alloc] initWithFrame: NSMakeRect(78, 15, 83, 18)];
|
||||
[v setIndeterminate: NO];
|
||||
[v setDoubleValue: 50.];
|
||||
[contents addSubview: v];
|
||||
RELEASE(v);
|
||||
|
||||
|
||||
/*******************/
|
||||
/* Third Column... */
|
||||
/*******************/
|
||||
|
||||
// Popup button
|
||||
v = [[NSPopUpButton alloc] initWithFrame: NSMakeRect(172, 127, 89, 20)];
|
||||
v = [[NSPopUpButton alloc] initWithFrame: NSMakeRect(172, 147, 89, 20)];
|
||||
[v addItemWithTitle: @"Item 1"];
|
||||
[v addItemWithTitle: @"Item 2"];
|
||||
[v addItemWithTitle: @"Item 3"];
|
||||
|
@ -146,7 +155,7 @@
|
|||
RELEASE(v);
|
||||
|
||||
// Form
|
||||
v = [[NSForm alloc] initWithFrame: NSMakeRect(172, 81, 87, 45)];
|
||||
v = [[NSForm alloc] initWithFrame: NSMakeRect(172, 101, 87, 45)];
|
||||
[v addEntry: @"Field 1"];
|
||||
[v addEntry: @"Field 2"];
|
||||
[v setEntryWidth: 87];
|
||||
|
@ -156,12 +165,12 @@
|
|||
RELEASE(v);
|
||||
|
||||
// Stepper
|
||||
v = [[NSStepper alloc] initWithFrame: NSMakeRect(172, 56, 16, 23)];
|
||||
v = [[NSStepper alloc] initWithFrame: NSMakeRect(172, 76, 16, 23)];
|
||||
[contents addSubview: v];
|
||||
RELEASE(v);
|
||||
|
||||
// CustomView
|
||||
v = [[GormCustomView alloc] initWithFrame: NSMakeRect(172, 9, 89, 40)];
|
||||
v = [[GormCustomView alloc] initWithFrame: NSMakeRect(172, 19, 89, 40)];
|
||||
[contents addSubview: v];
|
||||
RELEASE(v);
|
||||
}
|
||||
|
|
|
@ -25,13 +25,23 @@ include $(GNUSTEP_MAKEFILES)/common.make
|
|||
|
||||
PALETTE_NAME = 3Containers
|
||||
3Containers_PALETTE_ICON = ContainersPalette
|
||||
3Containers_OBJC_FILES = main.m inspectors.m GormNSBrowser.m \
|
||||
3Containers_OBJC_FILES = \
|
||||
main.m \
|
||||
inspectors.m \
|
||||
GormNSBrowser.m \
|
||||
GormNSTableView.m \
|
||||
GormTableViewEditor.m \
|
||||
GormNSOutlineView.m
|
||||
3Containers_HEADER_FILES = GormNSBrowser.h GormNSTableView.h \
|
||||
|
||||
3Containers_HEADER_FILES = \
|
||||
GormNSBrowser.h \
|
||||
GormNSTableView.h \
|
||||
GormTableViewEditor.h \
|
||||
GormNSOutlineView.h
|
||||
|
||||
3Containers_PRINCIPAL_CLASS = ContainersPalette
|
||||
3Containers_RESOURCE_FILES = ContainersPalette.tiff \
|
||||
3Containers_RESOURCE_FILES = \
|
||||
ContainersPalette.tiff \
|
||||
GormBrowserInspector.gorm \
|
||||
GormTableViewInspector.gorm \
|
||||
GormTableColumnInspector.gorm \
|
||||
|
|
|
@ -97,7 +97,6 @@ static id _sharedDelegate = nil;
|
|||
|
||||
- (void)encodeWithCoder: (NSCoder*) aCoder
|
||||
{
|
||||
id oldDelegate;
|
||||
_browserDelegate = _gormDelegate;
|
||||
[super encodeWithCoder: aCoder];
|
||||
_browserDelegate = _sharedDelegate;
|
||||
|
|
|
@ -285,7 +285,7 @@ static id _sharedDataSource = nil;
|
|||
return _gormDelegate;
|
||||
}
|
||||
|
||||
- (id)setGormDelegate: (id)anObject
|
||||
- (void)setGormDelegate: (id)anObject
|
||||
{
|
||||
[super setDelegate: anObject];
|
||||
}
|
||||
|
|
|
@ -34,4 +34,16 @@
|
|||
BOOL _gormAllowsMultipleSelection;
|
||||
BOOL _gormAllowsEmptySelection;
|
||||
}
|
||||
|
||||
- (void) setGormDelegate: (id)anObject;
|
||||
- (void) setGormAllowsColumnReordering: (BOOL)flag;
|
||||
- (BOOL) gormAllowsColumnReordering;
|
||||
- (void) setGormAllowsColumnResizing: (BOOL)flag;
|
||||
- (BOOL) gormAllowsColumnResizing;
|
||||
- (void) setGormAllowsMultipleSelection: (BOOL)flag;
|
||||
- (BOOL) gormAllowsMultipleSelection;
|
||||
- (void) setGormAllowsEmptySelection: (BOOL)flag;
|
||||
- (BOOL) gormAllowsEmptySelection;
|
||||
- (void) setGormAllowsColumnSelection: (BOOL)flag;
|
||||
- (BOOL) gormAllowsColumnSelection;
|
||||
@end
|
||||
|
|
|
@ -139,11 +139,11 @@
|
|||
Actions = (
|
||||
);
|
||||
Outlets = (
|
||||
titleAlignmentMatrix,
|
||||
contentsAlignmentMatrix,
|
||||
resizableSwitch,
|
||||
editableSwitch,
|
||||
identifierTextField
|
||||
identifierTextField,
|
||||
resizableSwitch,
|
||||
titleAlignmentMatrix
|
||||
);
|
||||
Super = IBInspector;
|
||||
};
|
||||
|
|
Binary file not shown.
33
Palettes/3Containers/GormTableViewEditor.h
Normal file
33
Palettes/3Containers/GormTableViewEditor.h
Normal file
|
@ -0,0 +1,33 @@
|
|||
/* GormTableViewEditor.h - Editor for tableviews.
|
||||
*
|
||||
* Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
*
|
||||
* Author: Pierre-Yves Rivaille
|
||||
* Date: Aug 2002
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#import "../../GormViewWithSubviewsEditor.h"
|
||||
|
||||
@class GormNSTableView;
|
||||
|
||||
@interface GormTableViewEditor : GormViewWithSubviewsEditor
|
||||
{
|
||||
GormNSTableView *tableView;
|
||||
}
|
||||
@end
|
413
Palettes/3Containers/GormTableViewEditor.m
Normal file
413
Palettes/3Containers/GormTableViewEditor.m
Normal file
|
@ -0,0 +1,413 @@
|
|||
/* GormTableViewEditor.m - Editor for matrices.
|
||||
*
|
||||
* Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
*
|
||||
* Author: Pierre-Yves Rivaille <pyrivail@ens-lyon.fr>
|
||||
* Date: 2002
|
||||
*
|
||||
* 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 "../../GormPrivate.h"
|
||||
|
||||
#import "GormTableViewEditor.h"
|
||||
#import "GormNSTableView.h"
|
||||
|
||||
NSString *IBTableColumnPboardType = @"IBTableColumnPboardType";
|
||||
|
||||
static NSCell *_editedCell;
|
||||
static NSCell *_currentHeaderCell;
|
||||
static NSText *_textObject;
|
||||
|
||||
@implementation NSScrollView (GormObjectAdditions)
|
||||
- (NSString*) editorClassName
|
||||
{
|
||||
if ([self documentView]
|
||||
&& [[self documentView] isKindOfClass: [NSTableView class]])
|
||||
return @"GormTableViewEditor";
|
||||
else
|
||||
return [super editorClassName];
|
||||
}
|
||||
@end
|
||||
|
||||
@interface GormTableViewEditor (Private)
|
||||
- (void) editHeader: (NSTableHeaderView*) th
|
||||
withEvent: (NSEvent *) theEvent;
|
||||
@end
|
||||
|
||||
@implementation GormTableViewEditor
|
||||
/*
|
||||
* Decide whether an editor can accept data from the pasteboard.
|
||||
*/
|
||||
- (BOOL) acceptsTypeFromArray: (NSArray*)types
|
||||
{
|
||||
// FIXME
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void) setOpened: (BOOL) flag
|
||||
{
|
||||
if (flag)
|
||||
[tableView setBackgroundColor: [NSColor whiteColor]];
|
||||
else
|
||||
{
|
||||
[tableView setBackgroundColor: [NSColor controlBackgroundColor]];
|
||||
[tableView deselectAll: self];
|
||||
}
|
||||
|
||||
[super setOpened: flag];
|
||||
}
|
||||
|
||||
/*
|
||||
* Activate an editor - inserts it into the view hierarchy or whatever is
|
||||
* needed for the editor to be able to provide its functionality.
|
||||
* This method should be called by the document when an editor is created
|
||||
* or opened. It should be safe to call repeatedly.
|
||||
*/
|
||||
- (BOOL) activate
|
||||
{
|
||||
NSLog(@"activate");
|
||||
|
||||
if ([super activate])
|
||||
{
|
||||
if ([_editedObject isKindOfClass: [NSScrollView class]])
|
||||
tableView = [(NSScrollView *)_editedObject documentView];
|
||||
else
|
||||
tableView = (GormNSTableView *)_editedObject;
|
||||
[tableView setAllowsColumnResizing: YES];
|
||||
[tableView setAllowsColumnSelection: YES];
|
||||
[tableView setAllowsMultipleSelection: NO];
|
||||
[tableView setAllowsEmptySelection: YES];
|
||||
[tableView setAllowsColumnReordering: YES];
|
||||
[tableView setGormDelegate: self];
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Deactivate an editor - removes it from the view hierarchy so that objects
|
||||
* can be archived without including the editor.
|
||||
* This method should be called automatically by the 'close' method.
|
||||
* It should be safe to call repeatedly.
|
||||
*/
|
||||
- (void) deactivate
|
||||
{
|
||||
if (activated == YES)
|
||||
{
|
||||
[tableView setBackgroundColor: [NSColor controlBackgroundColor]];
|
||||
if ([tableView selectedColumn] != -1)
|
||||
{
|
||||
[tableView deselectColumn: [tableView selectedColumn]];
|
||||
}
|
||||
[tableView setAllowsColumnResizing:
|
||||
[tableView gormAllowsColumnResizing]];
|
||||
[tableView setAllowsColumnSelection:
|
||||
[tableView gormAllowsColumnSelection]];
|
||||
[tableView setAllowsMultipleSelection:
|
||||
[tableView gormAllowsMultipleSelection]];
|
||||
[tableView setAllowsEmptySelection:
|
||||
[tableView gormAllowsEmptySelection]];
|
||||
[tableView setAllowsColumnReordering:
|
||||
[tableView gormAllowsColumnReordering]];
|
||||
[tableView setGormDelegate: nil];
|
||||
[tableView setNeedsDisplay: YES];
|
||||
[super deactivate];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* This method deletes all the objects in the current selection in the editor.
|
||||
*/
|
||||
- (void) deleteSelection
|
||||
{
|
||||
NSLog(@"deleteSelection");
|
||||
if ([selection count] == 0)
|
||||
{
|
||||
NSLog(@"no column to delete");
|
||||
}
|
||||
if ([tableView numberOfColumns] <= 1)
|
||||
{
|
||||
NSLog(@"can't delete last column");
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"FIXME: remove the tableColumn from toplevel"); // FIXME
|
||||
[tableView removeTableColumn: [selection objectAtIndex: 0]];
|
||||
[tableView deselectAll: self];
|
||||
[self selectObjects: [NSArray array]];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* This method places the current selection from the editor on the pasteboard.
|
||||
*/
|
||||
- (void) copySelection
|
||||
{
|
||||
NSLog(@"copySelection");
|
||||
if ([[[self selection] objectAtIndex: 0]
|
||||
isKindOfClass: [NSTableColumn class]])
|
||||
{
|
||||
[document copyObjects: [self selection]
|
||||
type: IBTableColumnPboardType
|
||||
toPasteboard: [NSPasteboard generalPasteboard]];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"no paste");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* This method is used to add the contents of the pasteboard to the current
|
||||
* selection of objects within the editor.
|
||||
*/
|
||||
- (void) pasteInSelection
|
||||
{
|
||||
NSArray *objects;
|
||||
NSLog(@"pasteInSelection");
|
||||
|
||||
|
||||
objects = [document pasteType: IBTableColumnPboardType
|
||||
fromPasteboard: [NSPasteboard generalPasteboard]
|
||||
parent: nil];
|
||||
|
||||
if (objects == nil)
|
||||
return;
|
||||
|
||||
if ([objects count] == 0)
|
||||
return;
|
||||
|
||||
if ([objects count] > 1)
|
||||
{
|
||||
NSLog(@"warning strange behaviour : GormTableViewEditor pasteInSelection");
|
||||
}
|
||||
else if ([[objects objectAtIndex: 0] isKindOfClass: [NSTableColumn class]]
|
||||
== NO)
|
||||
{
|
||||
NSLog(@"invalid data in IBTableColumnPboardType");
|
||||
return;
|
||||
}
|
||||
|
||||
[tableView addTableColumn: [objects objectAtIndex: 0]];
|
||||
|
||||
}
|
||||
|
||||
|
||||
- (void) mouseDown:(NSEvent*)theEvent
|
||||
{
|
||||
BOOL onKnob = NO;
|
||||
id hitView;
|
||||
|
||||
{
|
||||
if ([parent respondsToSelector: @selector(selection)] &&
|
||||
[[parent selection] containsObject: _editedObject])
|
||||
{
|
||||
IBKnobPosition knob = IBNoneKnobPosition;
|
||||
NSPoint mouseDownPoint =
|
||||
[self convertPoint: [theEvent locationInWindow]
|
||||
fromView: nil];
|
||||
knob = GormKnobHitInRect([self bounds],
|
||||
mouseDownPoint);
|
||||
if (knob != IBNoneKnobPosition)
|
||||
onKnob = YES;
|
||||
}
|
||||
if (onKnob == YES)
|
||||
{
|
||||
if (parent)
|
||||
return [parent mouseDown: theEvent];
|
||||
else
|
||||
return [self noResponderFor: @selector(mouseDown:)];
|
||||
}
|
||||
}
|
||||
|
||||
if (opened == NO)
|
||||
{
|
||||
NSLog(@"not opened");
|
||||
[super mouseDown: theEvent];
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
hitView =
|
||||
[[tableView enclosingScrollView]
|
||||
hitTest:
|
||||
[[[tableView enclosingScrollView] superview]
|
||||
convertPoint: [theEvent locationInWindow]
|
||||
fromView: nil]];
|
||||
|
||||
if (hitView == [tableView headerView])
|
||||
{
|
||||
if ([theEvent clickCount] == 2)
|
||||
{
|
||||
[self editHeader: hitView
|
||||
withEvent: theEvent];
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
[hitView mouseDown: theEvent];
|
||||
}
|
||||
}
|
||||
else if ([hitView isKindOfClass: [NSScroller class]])
|
||||
{
|
||||
[hitView mouseDown: theEvent];
|
||||
}
|
||||
else if (hitView == tableView)
|
||||
{
|
||||
if ([tableView selectedColumn] != -1)
|
||||
{
|
||||
[tableView deselectColumn: [tableView selectedColumn]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// - (void) changeObject: (id)anObject
|
||||
// {
|
||||
// if (tableView != nil)
|
||||
// {
|
||||
// if ([tableView selectedColumn] != -1)
|
||||
// {
|
||||
// [tableView deselectColumn: [tableView selectedColumn]];
|
||||
// }
|
||||
// [tableView setBackgroundColor: [NSColor controlBackgroundColor]];
|
||||
// }
|
||||
// ASSIGN(tableView, anObject);
|
||||
|
||||
// [tableView setBackgroundColor: [NSColor whiteColor]];
|
||||
// [tableView setNeedsDisplay: YES];
|
||||
// [self selectObjects: [NSArray arrayWithObject: tableView]];
|
||||
// [self activate];
|
||||
// }
|
||||
|
||||
|
||||
- (void) tableViewSelectionDidChange: (id) tv
|
||||
{
|
||||
if ([tableView selectedColumn] != -1)
|
||||
{
|
||||
[self selectObjects:
|
||||
[NSArray arrayWithObject:
|
||||
[[tableView tableColumns]
|
||||
objectAtIndex: [tableView selectedColumn]]]];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self selectObjects:
|
||||
[NSArray arrayWithObject: tableView]];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (void) outlineViewSelectionDidChange: (id) tv
|
||||
{
|
||||
if ([tableView selectedColumn] != -1)
|
||||
{
|
||||
[self selectObjects:
|
||||
[NSArray arrayWithObject:
|
||||
[[tableView tableColumns]
|
||||
objectAtIndex: [tableView selectedColumn]]]];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self selectObjects:
|
||||
[NSArray arrayWithObject: tableView]];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) editHeader: (NSTableHeaderView*) th
|
||||
withEvent: (NSEvent *) theEvent
|
||||
{
|
||||
NSText *t;
|
||||
NSTableColumn *tc;
|
||||
NSRect drawingRect;
|
||||
|
||||
int columnIndex = [th columnAtPoint:
|
||||
[th convertPoint:[theEvent locationInWindow]
|
||||
fromView: nil]];
|
||||
|
||||
if (columnIndex == NSNotFound)
|
||||
return;
|
||||
|
||||
_textObject = nil;
|
||||
|
||||
[[th tableView] scrollColumnToVisible: columnIndex];
|
||||
|
||||
|
||||
|
||||
t = [[th window] fieldEditor: YES forObject: self];
|
||||
|
||||
if ([t superview] != nil)
|
||||
{
|
||||
if ([t resignFirstResponder] == NO)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Prepare the cell
|
||||
tc = [[tableView tableColumns] objectAtIndex: columnIndex];
|
||||
// NB: need to be released when no longer used
|
||||
_editedCell = [[tc headerCell] copy];
|
||||
_currentHeaderCell = [tc headerCell];
|
||||
[_editedCell setStringValue: [[tc headerCell] stringValue]];
|
||||
[_editedCell setEditable: YES];
|
||||
// [_editedCell setAlignment: NSLeftTextAlignment];
|
||||
[(NSTableHeaderCell *)_editedCell setTextColor: [NSColor blackColor]];
|
||||
[(NSTableHeaderCell *)_editedCell setBackgroundColor: [NSColor whiteColor]];
|
||||
_textObject = [_editedCell setUpFieldEditorAttributes: t];
|
||||
|
||||
drawingRect = [th headerRectOfColumn: columnIndex];
|
||||
[_editedCell editWithFrame: drawingRect
|
||||
inView: th
|
||||
editor: _textObject
|
||||
delegate: self
|
||||
event: theEvent];
|
||||
return;
|
||||
}
|
||||
|
||||
- (void) textDidEndEditing: (NSNotification *)aNotification
|
||||
{
|
||||
[_editedCell endEditing: _textObject];
|
||||
[_currentHeaderCell setStringValue: [[_textObject text] copy]];
|
||||
|
||||
RELEASE(_editedCell);
|
||||
}
|
||||
|
||||
|
||||
// - (NSArray*) selection
|
||||
// {
|
||||
// if (tableView == nil)
|
||||
// return [NSArray array];
|
||||
// else if (selected == nil)
|
||||
// return [NSArray arrayWithObject: tableView];
|
||||
// else
|
||||
// return [NSArray arrayWithObject: selected];
|
||||
// }
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Binary file not shown.
|
@ -26,6 +26,8 @@
|
|||
#include <AppKit/AppKit.h>
|
||||
#include "../../GormPrivate.h"
|
||||
|
||||
#import "GormNSTableView.h"
|
||||
|
||||
/* This macro makes sure that the string contains a value, even if @"" */
|
||||
#define VSTR(str) ({id _str = str; (_str) ? _str : @"";})
|
||||
|
||||
|
@ -183,6 +185,8 @@
|
|||
id resizableSwitch;
|
||||
id editableSwitch;
|
||||
}
|
||||
- (void) _getValuesFromObject: (id)anObject;
|
||||
- (void) _setValuesFromControl: (id)anObject;
|
||||
@end
|
||||
|
||||
@implementation GormTableColumnAttributesInspector
|
||||
|
@ -316,6 +320,8 @@
|
|||
{
|
||||
id widthForm;
|
||||
}
|
||||
- (void) _getValuesFromObject: (id)anObject;
|
||||
- (void) _setValuesFromControl: (id)anObject;
|
||||
@end
|
||||
|
||||
@implementation GormTableColumnSizeInspector
|
||||
|
@ -397,8 +403,10 @@
|
|||
}
|
||||
|
||||
- (void) _getValuesFromObject: (id)anObject;
|
||||
- (void) _setValuesFromControl: (id)anObject;
|
||||
@end
|
||||
|
||||
|
||||
@implementation GormTableViewAttributesInspector
|
||||
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@
|
|||
|
||||
// NSBrowser
|
||||
// 124 is the minimum width. Below that the browser doesn't display !!
|
||||
v = [[GormNSBrowser alloc] initWithFrame: NSMakeRect(10, 38, 124, 116)];
|
||||
v = [[GormNSBrowser alloc] initWithFrame: NSMakeRect(10, 98, 124, 78)];
|
||||
|
||||
// [v setDelegate:nil];
|
||||
[v setHasHorizontalScroller: YES];
|
||||
|
@ -81,6 +81,32 @@
|
|||
// [v setMaxVisibleColumns: 3];
|
||||
//[v setAllowsMultipleSelection:NO];
|
||||
// [v setAutoresizingMask: NSViewHeightSizable|NSViewWidthSizable];
|
||||
|
||||
// NSTabView
|
||||
v = [[NSTabView alloc] initWithFrame: NSMakeRect(10, 10, 124, 78)];
|
||||
[contents addSubview: v];
|
||||
{
|
||||
NSView *vv;
|
||||
NSTabViewItem *tvi;
|
||||
tvi = [[NSTabViewItem alloc] initWithIdentifier: @"item 1"];
|
||||
[tvi setLabel: @"Item 1"];
|
||||
vv = [[NSView alloc] init];
|
||||
[vv setAutoresizingMask:
|
||||
NSViewWidthSizable | NSViewHeightSizable];
|
||||
[tvi setView: vv];
|
||||
[v addTabViewItem: tvi];
|
||||
RELEASE(tvi);
|
||||
tvi = [[NSTabViewItem alloc] initWithIdentifier: @"item 2"];
|
||||
[tvi setLabel: @"Item 2"];
|
||||
vv = [[NSView alloc] init];
|
||||
[vv setAutoresizingMask:
|
||||
NSViewWidthSizable | NSViewHeightSizable];
|
||||
[tvi setView: vv];
|
||||
[v addTabViewItem: tvi];
|
||||
RELEASE(tvi);
|
||||
}
|
||||
RELEASE(v);
|
||||
|
||||
|
||||
/********************/
|
||||
/* Second Column... */
|
||||
|
@ -97,7 +123,7 @@
|
|||
contentSize = [v contentSize];
|
||||
|
||||
tv = [[GormNSTableView alloc] initWithFrame:
|
||||
NSZeroRect];
|
||||
NSZeroRect];
|
||||
// [tv setDataSource: [[NSTableViewDataSource alloc] init]];
|
||||
// [tv setAutoresizesAllColumnsToFit: YES];
|
||||
[v setDocumentView: tv];
|
||||
|
@ -120,7 +146,6 @@
|
|||
[tc setEditable: YES];
|
||||
[tv addTableColumn: tc];
|
||||
RELEASE(tc);
|
||||
[tv setFrame: NSMakeRect(0,0,contentSize.width, contentSize.height)];
|
||||
|
||||
// [v setDocumentView: tv];
|
||||
[contents addSubview: v];
|
||||
|
@ -137,7 +162,7 @@
|
|||
contentSize = [v contentSize];
|
||||
|
||||
ov = [[GormNSOutlineView alloc] initWithFrame:
|
||||
NSMakeRect(0,0,contentSize.width, contentSize.height)];
|
||||
NSZeroRect];
|
||||
// [tv setAutoresizesAllColumnsToFit: YES];
|
||||
[v setDocumentView: ov];
|
||||
RELEASE(tv);
|
||||
|
@ -160,7 +185,6 @@
|
|||
[tc setEditable: YES];
|
||||
[ov addTableColumn: tc];
|
||||
RELEASE(tc);
|
||||
[ov setFrame: NSMakeRect(0,0,contentSize.width, contentSize.height)];
|
||||
[ov setDrawsGrid: NO];
|
||||
[ov setIndentationPerLevel: 10.];
|
||||
[ov setIndentationMarkerFollowsCell: YES];
|
||||
|
|
|
@ -254,6 +254,31 @@ extern NSArray *predefinedDateFormats, *predefinedNumberFormats;
|
|||
* NSTextView (possibly embedded in a Scroll view)
|
||||
*/
|
||||
|
||||
@interface GormViewSizeInspector : IBInspector
|
||||
{
|
||||
NSButton *top;
|
||||
NSButton *bottom;
|
||||
NSButton *left;
|
||||
NSButton *right;
|
||||
NSButton *width;
|
||||
NSButton *height;
|
||||
NSForm *sizeForm;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface GormTextViewSizeInspector : GormViewSizeInspector
|
||||
@end
|
||||
@implementation GormTextViewSizeInspector
|
||||
- (void) setObject: (id)anObject
|
||||
{
|
||||
id scrollView;
|
||||
scrollView = [anObject enclosingScrollView];
|
||||
|
||||
[super setObject: scrollView];
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
@implementation NSTextView (IBInspectorClassNames)
|
||||
|
||||
- (NSString*) inspectorClassName
|
||||
|
@ -261,6 +286,11 @@ extern NSArray *predefinedDateFormats, *predefinedNumberFormats;
|
|||
return @"GormTextViewAttributesInspector";
|
||||
}
|
||||
|
||||
- (NSString*) sizeInspectorClassName
|
||||
{
|
||||
return @"GormTextViewSizeInspector";
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@interface GormTextViewAttributesInspector : IBInspector
|
||||
|
@ -294,6 +324,7 @@ extern NSArray *predefinedDateFormats, *predefinedNumberFormats;
|
|||
else if ( (control == borderMatrix) && isScrollView)
|
||||
{
|
||||
[scrollView setBorderType: [[control selectedCell] tag]];
|
||||
[scrollView setNeedsDisplay: YES];
|
||||
}
|
||||
else if (control == optionMatrix)
|
||||
{
|
||||
|
|
|
@ -214,7 +214,7 @@ int defaultDateFormatIndex = 3;
|
|||
v = [[NSScrollView alloc] initWithFrame: NSMakeRect(20, 22, 113,148)];
|
||||
[v setHasVerticalScroller: YES];
|
||||
[v setHasHorizontalScroller: NO];
|
||||
[v setAutoresizingMask: NSViewHeightSizable|NSViewWidthSizable];
|
||||
// [v setAutoresizingMask: NSViewHeightSizable|NSViewWidthSizable];
|
||||
contentSize = [v contentSize];
|
||||
|
||||
tv = [[NSTextView alloc] initWithFrame:
|
||||
|
|
Loading…
Reference in a new issue