* Gorm.m: fixes segfault when leaving test mode.

* GormDocument.m: fixes bad reactivating of editors.
* GormBoxEditor.m: commented unused drag'n'drop code.
* GormCustomView.m: added GormTestCustomView class to deal with unknown
  class name without raising an exception.
* GormInspectorsManager.m: fix to deal with new NSBrowser behaviour.
* GormObjectEditor.m: ([GormObjectEditor -rectForObject:]):
  Corrected returned rect.
* GormInternalViewEditor.m:
* GormViewEditor.m:
  updated drag'n'drop support.
* GormWindowEditor.m: commented unused code.
* GormButtonEditor.m:
  inline editing of button's title.

* Palettes/0Menus/GormMenuEditor.m
* Palettes/0Menus/GormMenuInspectors.m
* Palettes/0Menus/GormNSMenu.h
* Palettes/0Menus/GormNSMenu.m
* Palettes/0Menus/main.m
  Updated menu editing to support NSPopUpButton.
  Basic tag editing added.

* Palettes/2Controls/GormPopUpButtonEditor.m
* Palettes/2Controls/GNUmakefile
* Palettes/2Controls/inspectors.m
* Palettes/2Controls/main.m
* GormDocument.m
* Gorm.m
  Added support for NSPopUpButton.

* Palettes/3Containers/GormTableViewEditor.m
  Updated drag'n'drop for object connectiion.

* Palettes/4Data/main.m
  updated NSTextView initialization so that it resizes properly.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@14502 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Pierre-Yves Rivaille 2002-09-21 15:24:59 +00:00
parent 4549ec7312
commit f9ad0e9a14
21 changed files with 1263 additions and 330 deletions

130
Gorm.m
View file

@ -206,6 +206,12 @@ NSString *GormLinkPboardType = @"GormLinkPboardType";
NSWindow *win;
BOOL edited = NO;
if (isTesting == YES)
{
[self endTesting: sender];
return NO;
}
while ((win = [enumerator nextObject]) != nil)
{
if ([win isDocumentEdited] == YES)
@ -347,8 +353,9 @@ NSString *GormLinkPboardType = @"GormLinkPboardType";
- (void) displayConnectionBetween: (id)source and: (id)destination
{
NSWindow *w;
NSRect r;
NSWindow *w, *neww;
NSRect r, newr;
if (source != connectSource)
{
@ -359,38 +366,21 @@ NSString *GormLinkPboardType = @"GormLinkPboardType";
if (w != nil)
{
NSView *wv = [[w contentView] superview];
r.origin.x --;
r.size.width ++;
r.size.height ++;
/*
* Erase image from old location.
*/
r.origin.y -= 1.0;
r.origin.x += 1.0;
r.size = [sourceImage size];
r.size.width += 2.0;
r.size.height += 2.0;
[wv lockFocus];
[w disableFlushWindow];
[wv displayRect: r];
[wv unlockFocus];
[w enableFlushWindow];
[w flushWindow];
}
}
connectSource = source;
}
if (connectSource != nil)
{
w = [[self activeDocument] windowAndRect: &r forObject: connectSource];
if (w != nil)
{
NSView *wv = [[w contentView] superview];
[wv lockFocus];
[sourceImage compositeToPoint: r.origin
operation: NSCompositeCopy];
[wv unlockFocus];
[w flushWindow];
}
}
if (destination != connectDestination)
{
if (connectDestination != nil)
@ -404,11 +394,9 @@ NSString *GormLinkPboardType = @"GormLinkPboardType";
/*
* Erase image from old location.
*/
r.origin.x -= 1.0;
r.origin.y += 1.0;
r.size = [targetImage size];
r.size.width += 2.0;
r.size.height += 2.0;
r.origin.x --;
r.size.width ++;
r.size.height ++;
[wv lockFocus];
[wv displayRect: r];
@ -418,7 +406,27 @@ NSString *GormLinkPboardType = @"GormLinkPboardType";
}
connectDestination = destination;
}
if (connectDestination != nil)
if (connectSource != nil)
{
w = [[self activeDocument] windowAndRect: &r forObject: connectSource];
if (w != nil)
{
NSView *wv = [[w contentView] superview];
r.origin.x++;
r.size.width--;
r.size.height--;
[wv lockFocus];
[[NSColor greenColor] set];
NSFrameRectWithWidth(r, 2);
[sourceImage compositeToPoint: r.origin
operation: NSCompositeSourceOver];
[wv unlockFocus];
[w flushWindow];
}
}
if (connectDestination != nil && connectDestination == connectSource)
{
w = [[self activeDocument] windowAndRect: &r
forObject: connectDestination];
@ -426,9 +434,38 @@ NSString *GormLinkPboardType = @"GormLinkPboardType";
{
NSView *wv = [[w contentView] superview];
r.origin.x += 3;
r.origin.y += 2;
r.size.width -= 5;
r.size.height -= 5;
[wv lockFocus];
[[NSColor purpleColor] set];
NSFrameRectWithWidth(r, 2);
r.origin.x += [targetImage size].width;
[targetImage compositeToPoint: r.origin
operation: NSCompositeCopy];
operation: NSCompositeSourceOver];
[wv unlockFocus];
[w flushWindow];
}
}
else if (connectDestination != nil)
{
w = [[self activeDocument] windowAndRect: &r
forObject: connectDestination];
if (w != nil)
{
NSView *wv = [[w contentView] superview];
r.origin.x++;
r.size.width--;
r.size.height--;
[wv lockFocus];
[[NSColor purpleColor] set];
NSFrameRectWithWidth(r, 2);
[targetImage compositeToPoint: r.origin
operation: NSCompositeSourceOver];
[wv unlockFocus];
[w flushWindow];
}
@ -464,6 +501,19 @@ NSString *GormLinkPboardType = @"GormLinkPboardType";
}
- (id) deferredEndTesting: (id) sender
{
[[NSRunLoop currentRunLoop]
performSelector: @selector(endTesting:)
target: self
argument: nil
order: 5000
modes: [NSArray arrayWithObjects:
NSDefaultRunLoopMode,
NSModalPanelRunLoopMode,
NSEventTrackingRunLoopMode, nil]];
}
- (id) endTesting: (id)sender
{
if (isTesting == NO)
@ -1136,6 +1186,12 @@ NSLog(@"StartupTime %f", [startDate timeIntervalSinceNow]);
intoClassName: @"NSWindow"];
[archiver encodeClassName: @"GormNSMenu"
intoClassName: @"NSMenu"];
[archiver encodeClassName: @"GormNSPopUpButton"
intoClassName: @"NSPopUpButton"];
[archiver encodeClassName: @"GormNSPopUpButtonCell"
intoClassName: @"NSPopUpButtonCell"];
[archiver encodeClassName: @"GormCustomView"
intoClassName: @"GormTestCustomView"];
[archiver encodeRootObject: a];
d = RETAIN([archiver archiverData]);
[a endArchiving];
@ -1172,7 +1228,7 @@ NSLog(@"StartupTime %f", [startDate timeIntervalSinceNow]);
testMenu = [[NSMenu alloc] initWithTitle: @"Test"];
[testMenu addItemWithTitle: @"Quit"
action: @selector(endTesting:)
action: @selector(deferredEndTesting:)
keyEquivalent: @"q"];
[self setMainMenu: testMenu];
RELEASE(testMenu);
@ -1185,12 +1241,12 @@ NSLog(@"StartupTime %f", [startDate timeIntervalSinceNow]);
item = [testMenu itemWithTitle: @"Quit"];
if (item != nil)
{
[item setAction: @selector(endTesting:)];
[item setAction: @selector(deferredEndTesting:)];
}
else
{
[testMenu addItemWithTitle: @"Quit"
action: @selector(endTesting:)
action: @selector(deferredEndTesting:)
keyEquivalent: @"q"];
}
}

View file

@ -434,236 +434,248 @@
- (unsigned) draggingEntered: (id<NSDraggingInfo>)sender
{
NSRect rect = [[_EO contentView] bounds];
NSPoint loc = [sender draggingLocation];
loc = [[_EO contentView]
convertPoint: loc fromView: nil];
// - (unsigned) draggingEntered: (id<NSDraggingInfo>)sender
// {
// NSRect rect = [[_EO contentView] bounds];
// NSPoint loc = [sender draggingLocation];
// NSPasteboard *dragPb;
// NSArray *types;
// dragPb = [sender draggingPasteboard];
// types = [dragPb types];
// 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;
// if ([types containsObject: GormLinkPboardType] == YES)
// {
// [NSApp displayConnectionBetween: [NSApp connectSource]
// and: _editedObject];
// NSLog(@"I said Yes !");
// return NSDragOperationLink;
// }
// 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];
// [[_EO contentView] lockFocus];
[[NSColor darkGrayColor] set];
NSFrameRectWithWidth(rect, 2);
// [[NSColor darkGrayColor] set];
// NSFrameRectWithWidth(rect, 2);
[[_EO contentView] unlockFocus];
[[self window] flushWindow];
return NSDragOperationCopy;
}
}
// [[_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;
// - (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 ++;
// 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];
}
// [[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];
// - (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;
// 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];
// 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);
// [[NSColor darkGrayColor] set];
// NSFrameRectWithWidth(rect, 2);
[[_EO contentView] unlockFocus];
[[self window] flushWindow];
return NSDragOperationCopy;
}
}
// [[_EO contentView] unlockFocus];
// [[self window] flushWindow];
// return NSDragOperationCopy;
// }
// }
- (BOOL) prepareForDragOperation: (id<NSDraggingInfo>)sender
{
NSString *dragType;
NSArray *types;
NSPasteboard *dragPb;
// - (BOOL) prepareForDragOperation: (id<NSDraggingInfo>)sender
// {
// NSString *dragType;
// NSArray *types;
// NSPasteboard *dragPb;
NSLog(@"prepareForDragOperation called");
// NSLog(@"prepareForDragOperation called");
dragPb = [sender draggingPasteboard];
// dragPb = [sender draggingPasteboard];
types = [dragPb types];
// 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 ([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;
}
// 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 YES;
// }
return NO;
}
// return NO;
// }
- (BOOL) performDragOperation: (id<NSDraggingInfo>)sender
{
NSString *dragType;
NSPasteboard *dragPb;
NSArray *types;
// - (BOOL) performDragOperation: (id<NSDraggingInfo>)sender
// {
// NSString *dragType;
// NSPasteboard *dragPb;
// NSArray *types;
dragPb = [sender draggingPasteboard];
// dragPb = [sender draggingPasteboard];
types = [dragPb types];
// 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 ([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 (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");
}
*/
// /*
// 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];
// /*
// * 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];
// 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];
// [[_EO contentView] addSubview: sub];
[self selectObjects:
[NSArray arrayWithObject:
[document editorForObject: sub
inEditor: self
create: YES]]];
}
// FIXME we should maybe open ourself
}
// [self selectObjects:
// [NSArray arrayWithObject:
// [document editorForObject: sub
// inEditor: self
// create: YES]]];
// }
// // FIXME we should maybe open ourself
// }
return YES;
}
// return YES;
// }
// - (void) pasteInSelection

View file

@ -29,6 +29,8 @@
#import "GormButtonEditor.h"
#import "GormViewWithSubviewsEditor.h"
#import "Gorm.h"
#define _EO ((NSButton *)_editedObject)
@ -297,36 +299,283 @@
@end
static BOOL done_editing;
static NSRect oldFrame;
@implementation GormButtonEditor
- (void) handleNotification: (NSNotification*)aNotification
{
NSString *name = [aNotification name];
if ([name isEqual: NSControlTextDidEndEditingNotification] == YES)
{
done_editing = YES;
}
}
- (void) textDidChange: (NSNotification *)aNotification
{
[_EO setTitle: [[aNotification object] string]];
[_EO setNeedsDisplay: NO];
[[(Gorm*)NSApp inspectorsManager] updateSelection];
}
- (void) textDidEndEditing: (NSNotification *)aNotification
{
[[aNotification object] setDelegate: nil];
[_EO setTitle: [[aNotification object] string]];
[[aNotification object] removeFromSuperview];
{
NSSize suggestedSize;
NSRect newFrame = [_EO frame];
suggestedSize = [[_EO cell] cellSize];
if (suggestedSize.width > newFrame.size.width)
{
newFrame.origin.x = newFrame.origin.x
- (int)((suggestedSize.width - newFrame.size.width) / 2);
newFrame.size.width = suggestedSize.width;
[_EO setFrame: newFrame];
[[self window] disableFlushWindow];
[[self window] display];
[[self window] enableFlushWindow];
[[self window] flushWindow];
}
}
}
/* Edit a textfield. If it's not already editable, make it so, then
edit it */
- (NSEvent *) editTextField: view withEvent: (NSEvent *)theEvent
{
unsigned eventMask;
BOOL wasEditable;
BOOL didDrawBackground;
NSTextField *editField;
NSRect frame;
NSRect originalFrame;
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
NSDate *future = [NSDate distantFuture];
NSEvent *e;
editField = view;
originalFrame = frame = [editField frame];
wasEditable = [editField isEditable];
[editField setEditable: YES];
didDrawBackground = [editField drawsBackground];
[editField setDrawsBackground: YES];
// [editField display];
[nc addObserver: self
selector: @selector(handleNotification:)
name: NSControlTextDidEndEditingNotification
object: nil];
/* Do some modal editing */
[editField selectText: self];
eventMask = NSLeftMouseDownMask | NSLeftMouseUpMask |
NSKeyDownMask | NSKeyUpMask | NSFlagsChangedMask;
done_editing = NO;
while (!done_editing)
{
NSEventType eType;
e = [NSApp nextEventMatchingMask: eventMask
untilDate: future
inMode: NSEventTrackingRunLoopMode
dequeue: YES];
eType = [e type];
switch (eType)
{
case NSLeftMouseDown:
{
NSPoint dp = [self convertPoint: [e locationInWindow]
fromView: nil];
if (NSMouseInRect(dp, frame, NO) == NO)
{
done_editing = YES;
break;
}
}
[[editField currentEditor] mouseDown: e];
break;
case NSLeftMouseUp:
[[editField currentEditor] mouseUp: e];
break;
case NSLeftMouseDragged:
[[editField currentEditor] mouseDragged: e];
break;
case NSKeyDown:
[[editField currentEditor] keyDown: e];
// {
// NSSize suggestedSize;
// suggestedSize = [[(NSTextView *)[editField currentEditor] textStorage] size];
// if (suggestedSize.width > originalFrame.size.width)
// {
// frame.origin.x = originalFrame.origin.x
// - (int)((suggestedSize.width - originalFrame.size.width) / 2);
// frame.size.width = suggestedSize.width;
// [editField setFrame: frame];
// [[(NSTextView*)[editField currentEditor]
// layoutManager] invalidateLayoutForCharacterRange: NSMakeRange(0, [[[editField currentEditor] string] length])
// isSoft: NO
// actualCharacterRange: NULL];
// NSLog(@"%@ %@ %@",
// NSStringFromRect([[editField currentEditor] frame]),
// NSStringFromRect(frame),
// [[editField currentEditor] string]);
// [[self window] disableFlushWindow];
// [[self window] display];
// // [[editField currentEditor]
// // setString: [editField stringValue]];
// [editField display];
// [[self window] enableFlushWindow];
// [[self window] flushWindow];
// }
// }
break;
case NSKeyUp:
[[editField currentEditor] keyUp: e];
break;
case NSFlagsChanged:
[[editField currentEditor] flagsChanged: e];
break;
default:
NSLog(@"Internal Error: Unhandled event during editing: %@", e);
break;
}
}
[editField setEditable: wasEditable];
[editField setDrawsBackground: didDrawBackground];
[nc removeObserver: self
name: NSControlTextDidEndEditingNotification
object: nil];
[[editField currentEditor] resignFirstResponder];
[self setNeedsDisplay: YES];
return e;
}
- (NSTextView *) startEditingInFrame: (NSRect) frame
{
NSTextView *textView = [[NSTextView alloc] initWithFrame: frame];
NSTextContainer *textContainer = [textView textContainer];
[textContainer setContainerSize: NSMakeSize(3000, NSHeight([textView frame]))];
[textContainer setWidthTracksTextView: NO];
[textContainer setHeightTracksTextView: NO];
[textView setMinSize: frame.size];
[textView setAutoresizingMask: NSViewMinXMargin | NSViewMaxXMargin];
[textView setSelectable: YES];
[textView setEditable: YES];
[textView setRichText: NO];
[textView setImportsGraphics: NO];
[textView setFieldEditor: YES];
[textView setHorizontallyResizable: YES];
[textView setDelegate: self];
[textView setPostsFrameChangedNotifications:YES];
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(textViewFrameChanged:)
name: NSViewFrameDidChangeNotification
object: textView];
oldFrame = frame;
return textView;
}
- (void) textViewFrameChanged: (NSNotification *)aNot
{
static BOOL inside = NO;
NSRect newFrame;
if (inside)
return;
inside = YES;
[[[self window] contentView] setNeedsDisplayInRect: oldFrame];
newFrame = [[aNot object] frame];
if ([[aNot object] alignment] == NSCenterTextAlignment)
{
NSRect frame = [[_EO cell]
gormTitleRectForFrame: [_EO frame]
inView: _EO];
int difference = newFrame.size.width - frame.size.width;
newFrame.origin.x = frame.origin.x - (int) (difference / 2);
[[aNot object] setFrame: newFrame];
oldFrame = newFrame;
}
[[[self window] contentView] setNeedsDisplayInRect: oldFrame];
inside = NO;
}
- (void) mouseDown: (NSEvent*)theEvent
{
if (([theEvent clickCount] == 2) && [parent isOpened])
// double-clicked -> let's edit
{
NSTextField *tf =
[[NSTextField alloc] initWithFrame: [self bounds]];
// 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 window] contentView] addSubview: tf];
// [tf setStringValue: [_EO stringValue]];
// [self editTextField: tf
// withEvent: theEvent];
// [_EO setStringValue: [tf stringValue]];
// {
// NSSize suggestedSize;
// NSRect newFrame = [_EO frame];
// suggestedSize = [[_EO cell] cellSize];
// if (suggestedSize.width > newFrame.size.width)
// {
// newFrame.origin.x = newFrame.origin.x
// - (int)((suggestedSize.width - newFrame.size.width) / 2);
// newFrame.size.width = suggestedSize.width;
// [_EO setFrame: newFrame];
// [[self window] disableFlushWindow];
// [[self window] display];
// [[self window] enableFlushWindow];
// }
// }
// [tf removeFromSuperview];
// RELEASE(tf);
// [[NSNotificationCenter defaultCenter]
// postNotificationName: IBSelectionChangedNotification
// object: parent];
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];
inView: _EO];
// frame.origin.y -= 2;
// frame.size.height = 2;
NSTextView *tv = [self startEditingInFrame: frame];
[[[self window] contentView] addSubview: tv];
[tv setText: [_EO stringValue]];
[tv setAlignment: [_EO alignment]];
[tv setFont: [_EO font]];
[[self window] display];
[[self window] makeFirstResponder: tv];
[tv mouseDown: theEvent];
}
else
{

View file

@ -27,6 +27,8 @@
#include <AppKit/NSGraphics.h>
#include <AppKit/NSFont.h>
#import <AppKit/NSNibLoading.h>
@class GSCustomView;
@implementation GormCustomView
@ -61,10 +63,10 @@
}
- (Class) classForCoder
{
return [GSCustomView class];
}
// - (Class) classForCoder
// {
// return [GSCustomView class];
// }
/*
* This needs to be coded like a GSNibItem. How do we make sure this
@ -117,3 +119,51 @@
@end
@interface GormTestCustomView : GSNibItem <NSCoding>
{
}
@end
@implementation GormTestCustomView
- (id) initWithCoder: (NSCoder*)aCoder
{
id obj;
Class cls;
unsigned int mask;
[aCoder decodeValueOfObjCType: @encode(id) at: &theClass];
theFrame = [aCoder decodeRect];
[aCoder decodeValueOfObjCType: @encode(unsigned int)
at: &mask];
cls = NSClassFromString(theClass);
if (cls == nil)
{
cls = [NSView class];
}
obj = [cls allocWithZone: [self zone]];
if (theFrame.size.height > 0 && theFrame.size.width > 0)
obj = [obj initWithFrame: theFrame];
else
obj = [obj init];
if ([obj respondsToSelector: @selector(setAutoresizingMask:)])
{
[obj setAutoresizingMask: mask];
}
if (![self isKindOfClass: [GSCustomView class]])
{
RETAIN(obj);
}
RELEASE(self);
return obj;
}
@end

View file

@ -274,7 +274,6 @@ static NSImage *classesImage = nil;
else
{
NSString *name;
obj = [con source];
name = [self nameForObject: obj];
[con setSource: name];
@ -989,7 +988,6 @@ static NSImage *classesImage = nil;
while ((con = [enumerator nextObject]) != nil)
{
NSString *name;
name = (NSString*)[con source];
obj = [self objectForName: name];
[con setSource: obj];
@ -1005,7 +1003,8 @@ static NSImage *classesImage = nil;
enumerator = [savedEditors objectEnumerator];
while ((con = [enumerator nextObject]) != nil)
{
[[con destination] activate];
if ([[con source] isKindOfClass: [NSView class]] == NO)
[[con destination] activate];
}
[savedEditors removeAllObjects];
}
@ -1465,6 +1464,8 @@ static NSImage *classesImage = nil;
[u decodeClassName: @"NSBrowser" asClassName: @"GormNSBrowser"];
[u decodeClassName: @"NSTableView" asClassName: @"GormNSTableView"];
[u decodeClassName: @"NSOutlineView" asClassName: @"GormNSOutlineView"];
[u decodeClassName: @"NSPopUpButton" asClassName: @"GormNSPopUpButton"];
[u decodeClassName: @"NSPopUpButtonCell" asClassName: @"GormNSPopUpButtonCell"];
c = [u decodeObject];
if (c == nil || [c isKindOfClass: [GSNibContainer class]] == NO)
@ -2043,6 +2044,10 @@ static NSImage *classesImage = nil;
intoClassName: @"NSTableView"];
[archiver encodeClassName: @"GormNSOutlineView"
intoClassName: @"NSOutlineView"];
[archiver encodeClassName: @"GormNSPopUpButton"
intoClassName: @"NSPopUpButton"];
[archiver encodeClassName: @"GormNSPopUpButtonCell"
intoClassName: @"NSPopUpButtonCell"];
[archiver encodeRootObject: self];
archiveResult = [archiverData writeToFile: documentPath atomically: YES];
//archiveResult = [NSArchiver archiveRootObject: self toFile: documentPath];
@ -2180,7 +2185,7 @@ static NSImage *classesImage = nil;
else if ([editor respondsToSelector:
@selector(windowAndRect:forObject:)])
{
NSLog(@"temp != nil");
// NSLog(@"temp != nil");
return [editor windowAndRect: r forObject: object];
}
}
@ -2210,7 +2215,7 @@ static NSImage *classesImage = nil;
*r = [th convertRect: [th headerRectOfColumn: index]
toView: nil];
NSLog(@"%@", NSStringFromRect(*r));
// NSLog(@"%@", NSStringFromRect(*r));
return [th window];
}
else

View file

@ -635,6 +635,23 @@
}
}
- (void) _internalCall: (id) sender
{
if (sender == newBrowser)
{
[self browser: newBrowser
selectCellWithString: [[newBrowser selectedCell] stringValue]
inColumn: [newBrowser selectedColumn]];
[newBrowser reloadColumn: 1];
}
else if (sender == oldBrowser)
{
[self browser: oldBrowser
selectCellWithString: [[oldBrowser selectedCell] stringValue]
inColumn: [oldBrowser selectedColumn]];
}
}
- (BOOL) browser: (NSBrowser*)sender
selectCellWithString: (NSString*)title
inColumn: (int)col
@ -642,6 +659,7 @@ selectCellWithString: (NSString*)title
unsigned numConnectors = [connectors count];
unsigned index;
if (sender == newBrowser)
{
if (col == 0)
@ -651,6 +669,7 @@ selectCellWithString: (NSString*)title
id con = nil;
NSString *action;
for (index = 0; index < numConnectors; index++)
{
con = [connectors objectAtIndex: index];
@ -676,17 +695,17 @@ selectCellWithString: (NSString*)title
AUTORELEASE(con);
}
}
if (currentConnector != con)
{
ASSIGN(currentConnector, con);
[newBrowser setLastColumn: 0];
}
action = [con label];
if (action != nil)
{
[newBrowser selectRow: [actions indexOfObject: action]
inColumn: 1];
}
if (currentConnector != con)
{
ASSIGN(currentConnector, con);
// [newBrowser setLastColumn: 0];
}
action = [con label];
if (action != nil)
{
[newBrowser selectRow: [actions indexOfObject: action]
inColumn: 1];
}
}
else
{
@ -901,6 +920,8 @@ selectCellWithString: (NSString*)title
[newBrowser setAllowsMultipleSelection: NO];
[newBrowser setHasHorizontalScroller: NO];
[newBrowser setDelegate: self];
[newBrowser setTarget: self];
[newBrowser setAction: @selector(_internalCall:)];
[split addSubview: newBrowser];
RELEASE(newBrowser);
@ -912,6 +933,8 @@ selectCellWithString: (NSString*)title
[oldBrowser setAllowsMultipleSelection: NO];
[oldBrowser setHasHorizontalScroller: NO];
[oldBrowser setDelegate: self];
[newBrowser setTarget: self];
[newBrowser setAction: @selector(_internalCall:)];
[split addSubview: oldBrowser];
RELEASE(oldBrowser);

View file

@ -320,7 +320,7 @@
if ([parent isOpened] == NO)
{
NSDebugLog(@"md %@ calling my parent %@", self, parent);
[super mouseDown: theEvent];
[parent mouseDown: theEvent];
return;
}
}
@ -534,8 +534,18 @@
{
NSRect rect = [_editedObject bounds];
NSPoint loc = [sender draggingLocation];
NSPasteboard *dragPb;
NSArray *types;
dragPb = [sender draggingPasteboard];
types = [dragPb types];
loc = [_editedObject convertPoint: loc fromView: nil];
if ([types containsObject: GormLinkPboardType] == YES)
{
return [parent draggingEntered: sender];
}
if (NSMouseInRect(loc, [_editedObject bounds], NO) == NO)
{
return NSDragOperationNone;
@ -560,6 +570,18 @@
- (void) draggingExited: (id<NSDraggingInfo>)sender
{
NSPasteboard *dragPb;
NSArray *types;
dragPb = [sender draggingPasteboard];
types = [dragPb types];
if ([types containsObject: GormLinkPboardType] == YES)
{
[parent draggingExited: sender];
return;
}
NSRect rect = [_editedObject bounds];
rect.origin.x += 3;
rect.origin.y += 2;
@ -582,9 +604,19 @@
{
NSPoint loc = [sender draggingLocation];
NSRect rect = [_editedObject bounds];
NSPasteboard *dragPb;
NSArray *types;
dragPb = [sender draggingPasteboard];
types = [dragPb types];
loc = [_editedObject
convertPoint: loc fromView: nil];
if ([types containsObject: GormLinkPboardType] == YES)
{
return [parent draggingUpdated: sender];
}
rect.origin.x += 3;
rect.origin.y += 2;
rect.size.width -= 5;
@ -636,6 +668,7 @@
else if ([types containsObject: GormLinkPboardType] == YES)
{
dragType = GormLinkPboardType;
return [parent prepareForDragOperation: sender];
}
else if ([types containsObject: IBFormatterPboardType] == YES)
{

View file

@ -251,7 +251,7 @@ static NSMapTable *docMap = 0;
}
if (obj == [NSApp connectSource])
{
return 0; /* Can't drag an object onto itsself */
return NSDragOperationNone; /* Can't drag an object onto itsself */
}
[NSApp displayConnectionBetween: [NSApp connectSource] and: obj];
if (obj != nil)
@ -260,12 +260,12 @@ static NSMapTable *docMap = 0;
}
else
{
return 0;
return NSDragOperationNone;
}
}
else
{
return 0;
return NSDragOperationNone;
}
}
@ -545,7 +545,7 @@ static NSMapTable *docMap = 0;
/*
* Adjust to image area.
*/
rect.size.width -= 15;
// rect.size.width -= 15;
rect.size.height -= 15;
rect = [self convertRect: rect toView: nil];
return rect;

View file

@ -288,7 +288,7 @@ static BOOL currently_displaying = NO;
- (GormPlacementInfo *) initializeResizingInFrame: (NSView *)view
withKnob: (IBKnobPosition) knob
withKnob: (IBKnobPosition) knob
{
GormPlacementInfo *gip;
gip = [[GormPlacementInfo alloc] init];
@ -802,9 +802,6 @@ static BOOL currently_displaying = NO;
}
}
- (NSRect) _displayMovingFrameWithHint: (NSRect) frame
andPlacementInfo: (GormPlacementInfo*)gpi
{
@ -1200,13 +1197,11 @@ static BOOL currently_displaying = NO;
}
- (NSWindow*) windowAndRect: (NSRect *)rect forObject: (id) anObject
{
if (anObject != _editedObject)
{
NSLog(@"%@ windowAndRect: object unknown", self);
// NSLog(@"%@ windowAndRect: object unknown", self);
return nil;
}
else
@ -1218,7 +1213,6 @@ static BOOL currently_displaying = NO;
}
- (void) startConnectingObject: (id) anObject
withEvent: (NSEvent *)theEvent
{
@ -1248,7 +1242,7 @@ static BOOL currently_displaying = NO;
- (BOOL) acceptsTypeFromArray: (NSArray*)types
{
// NSLog(@"I said why not !");
NSLog(@"I said why not !");
return [types containsObject: GormLinkPboardType];
}
@ -1272,6 +1266,41 @@ static BOOL currently_displaying = 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: _editedObject];
return NSDragOperationLink;
}
else
{
// NSLog(@"I said None !");
return NSDragOperationNone;
}
}
- (void) draggingExited: (id<NSDraggingInfo>)sender
{
NSPasteboard *dragPb;
NSArray *types;
dragPb = [sender draggingPasteboard];
types = [dragPb types];
if ([types containsObject: GormLinkPboardType] == YES)
{
[NSApp displayConnectionBetween: [NSApp connectSource]
and: nil];
}
}
- (void) mouseDown: (NSEvent*)theEvent
{

View file

@ -1514,7 +1514,6 @@
if (activated == NO)
{
NSView *contentView = [_EO contentView];
// NSLog(@"contentView %@", contentView);
contentViewEditor = [document editorForObject: contentView
inEditor: self
@ -1751,8 +1750,11 @@
- (unsigned) draggingEntered: (id<NSDraggingInfo>)sender
{
NSLog(@"********* TELL pyr *********** draggingEntered");
return NSDragOperationNone;
}
// - (unsigned) draggingEntered: (id<NSDraggingInfo>)sender
// {
// NSArray *types;
// dragPb = [sender draggingPasteboard];
@ -1774,12 +1776,15 @@
// dragType = nil;
// }
// return [self draggingUpdated: sender];
}
// }
- (unsigned) draggingUpdated: (id<NSDraggingInfo>)sender
{
NSLog(@"********* TELL pyr *********** draggingUpdated");
return NSDragOperationNone;
}
// - (unsigned) draggingUpdated: (id<NSDraggingInfo>)sender
// {
// if (dragType == IBViewPboardType)
// {
// return NSDragOperationCopy;
@ -1811,7 +1816,7 @@
// {
// return NSDragOperationNone;
// }
}
// }
- (void) drawSelection
{
@ -2060,9 +2065,11 @@
- (BOOL) prepareForDragOperation: (id<NSDraggingInfo>)sender
{
NSLog(@"********* TELL pyr *********** prepareForDragOperation");
return NO;
}
// - (BOOL) prepareForDragOperation: (id<NSDraggingInfo>)sender
// {
// /*
// * Tell the source that we will accept the drop if we can.
// */
@ -2102,7 +2109,7 @@
// }
// return NO;
}
// }
- (void) resetObject: (id)anObject
{

View file

@ -48,6 +48,11 @@
}
@end
@interface NSButtonCell (GormObjectAdditions)
- (NSRect) gormTitleRectForFrame: (NSRect) cellFrame
inView: (NSView *)controlView;
@end
@interface GormMenuEditor : NSMenuView <IBEditors, IBSelectionOwners>
@ -135,6 +140,36 @@
{
NSMenuItem *item = [edited itemAtIndex: pos];
if ([theEvent clickCount] == 2)
{
[self makeSelectionVisible: NO];
[self selectObjects: [NSArray array]];
id cell = [rep menuItemCellForItemAtIndex: pos];
NSTextField *tf =
[[NSTextField alloc] initWithFrame: [self bounds]];
NSRect frame = (NSRect)[cell titleRectForBounds:
[rep rectOfItemAtIndex: pos]];
NSLog(@"cell %@ (%@)", cell, [cell stringValue]);
frame.origin.y += 3;
frame.size.height -= 5;
frame.origin.x += 1;
frame.size.width += 3;
[tf setFrame: frame];
[tf setEditable: YES];
[tf setBezeled: NO];
[tf setBordered: NO];
// [tf setAlignment: [_EO alignment]];
// [tf setFont: [_EO font]];
[self addSubview: tf];
[tf setStringValue: [[cell menuItem] title]];
[self editTextField: tf
withEvent: theEvent];
[[cell menuItem] setTitle: [tf stringValue]];
[tf removeFromSuperview];
RELEASE(tf);
return;
}
[self makeSelectionVisible: NO];
if ([theEvent modifierFlags] & NSShiftKeyMask)
{
@ -412,7 +447,6 @@
- (void) deactivate
{
NSLog(@"deactivate");
if (original != nil)
{
NSEnumerator *enumerator;
@ -535,6 +569,16 @@
}
}
- (void) draggingExited: (id<NSDraggingInfo>)sender
{
if (dragType == GormLinkPboardType)
{
[NSApp displayConnectionBetween: [NSApp connectSource]
and: nil];
}
}
- (void) drawSelection
{
}
@ -697,16 +741,16 @@
enumerator = [items objectEnumerator];
while ((item = [enumerator nextObject]) != nil)
{
NSString *title = [item title];
// NSString *title = [item title];
if ([edited indexOfItemWithTitle: title] > 0)
{
[document detachObject: item]; /* Already exists */
}
else
{
// if ([edited indexOfItemWithTitle: title] > 0)
// {
// [document detachObject: item]; /* Already exists */
// }
// else
// {
[edited insertItem: item atIndex: pos++];
}
// }
}
[edited sizeToFit];
[edited display];
@ -792,6 +836,7 @@ NSLog(@"Link at index: %d (%@)", pos, NSStringFromPoint(loc));
NSMenuItem *item;
[selection removeAllObjects];
NSLog(@"selectObjects %@ %@", selection, anArray);
[selection addObjectsFromArray: anArray];
count = [selection count];
@ -889,3 +934,105 @@ NSLog(@"Link at index: %d (%@)", pos, NSStringFromPoint(loc));
return [super window];
}
@end
static BOOL done_editing;
@implementation GormMenuEditor (EditingAdditions)
- (void) handleNotification: (NSNotification*)aNotification
{
NSString *name = [aNotification name];
if ([name isEqual: NSControlTextDidEndEditingNotification] == YES)
{
done_editing = YES;
}
}
/* Edit a textfield. If it's not already editable, make it so, then
edit it */
- (NSEvent *) editTextField: view withEvent: (NSEvent *)theEvent
{
unsigned eventMask;
BOOL wasEditable;
BOOL didDrawBackground;
NSTextField *editField;
NSRect frame;
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
NSDate *future = [NSDate distantFuture];
NSEvent *e;
editField = view;
frame = [editField frame];
wasEditable = [editField isEditable];
[editField setEditable: YES];
didDrawBackground = [editField drawsBackground];
[editField setDrawsBackground: YES];
// [editField display];
[nc addObserver: self
selector: @selector(handleNotification:)
name: NSControlTextDidEndEditingNotification
object: nil];
/* Do some modal editing */
[editField selectText: self];
eventMask = NSLeftMouseDownMask | NSLeftMouseUpMask |
NSKeyDownMask | NSKeyUpMask | NSFlagsChangedMask;
done_editing = NO;
while (!done_editing)
{
NSEventType eType;
e = [NSApp nextEventMatchingMask: eventMask
untilDate: future
inMode: NSEventTrackingRunLoopMode
dequeue: YES];
eType = [e type];
switch (eType)
{
case NSLeftMouseDown:
{
NSPoint dp = [self convertPoint: [e locationInWindow]
fromView: nil];
if (NSMouseInRect(dp, frame, NO) == NO)
{
done_editing = YES;
break;
}
}
[[editField currentEditor] mouseDown: e];
break;
case NSLeftMouseUp:
[[editField currentEditor] mouseUp: e];
break;
case NSLeftMouseDragged:
[[editField currentEditor] mouseDragged: e];
break;
case NSKeyDown:
[[editField currentEditor] keyDown: e];
break;
case NSKeyUp:
[[editField currentEditor] keyUp: e];
break;
case NSFlagsChanged:
[[editField currentEditor] flagsChanged: e];
break;
default:
NSLog(@"Internal Error: Unhandled event during editing: %@", e);
break;
}
}
[editField setEditable: wasEditable];
[editField setDrawsBackground: didDrawBackground];
[nc removeObserver: self
name: NSControlTextDidEndEditingNotification
object: nil];
[[editField currentEditor] resignFirstResponder];
[self setNeedsDisplay: YES];
return e;
}
@end

View file

@ -76,6 +76,8 @@
[titleText setDelegate: self];
[contents addSubview: titleText];
RELEASE(titleText);
}
return self;
}
@ -101,6 +103,7 @@
{
NSTextField *titleText;
NSTextField *shortCut;
NSTextField *tagText;
}
@end
@ -120,6 +123,10 @@
[object setKeyEquivalent: s];
}
if (o == tagText)
{
[object setTag: [tagText intValue]];
}
[[object menu] display];
}
@ -173,6 +180,12 @@
[shortCut setDelegate: self];
[contents addSubview: shortCut];
RELEASE(shortCut);
tagText
= [[NSTextField alloc] initWithFrame: NSMakeRect(60,IVH-90,IVW-80,20)];
[tagText setDelegate: self];
[contents addSubview: tagText];
RELEASE(tagText);
}
return self;
}
@ -182,6 +195,8 @@
[super setObject: anObject];
[titleText setStringValue: [object title]];
[shortCut setStringValue: [object keyEquivalent]];
[tagText setIntValue: [object tag]];
}
@end

View file

@ -24,7 +24,10 @@
#import <AppKit/AppKit.h>
@class GormDocument;
@interface GormNSMenu : NSMenu
{
NSMenu *_menu;
}
@end

View file

@ -26,6 +26,7 @@
@interface GormNSMenuWindow : NSWindow
{
GormDocument *_document;
}
@end
@ -38,6 +39,43 @@
{
return YES;
}
- (void)setMenu: (NSMenu*)menu;
{
_menu = menu;
}
- (void)setDocument: (GormDocument *)document
{
_document = document;
}
- (void)resignMainWindow
{
[super resignMainWindow];
if ([_menu _ownedByPopUp])
{
[[NSRunLoop currentRunLoop]
performSelector: @selector(close)
target: _menu
argument: nil
order: 500000
modes: [NSArray arrayWithObjects:
NSDefaultRunLoopMode,
NSModalPanelRunLoopMode,
NSEventTrackingRunLoopMode, nil]];
}
}
- (void)becomeMainWindow
{
[super becomeMainWindow];
if ([_menu _ownedByPopUp] )
{
}
}
- (void) sendEvent: (NSEvent*)theEvent
{
NSEventType type;
@ -45,10 +83,9 @@
type = [theEvent type];
if (type == NSLeftMouseDown)
{
NSLog(@"here");
if (_f.is_main == YES)
{
NSLog(@"already main %@", [NSApp mainWindow]);
// NSLog(@"already main %@", [NSApp mainWindow]);
}
[self makeMainWindow];
[self makeKeyWindow];
@ -60,6 +97,7 @@
@end
@implementation GormNSMenu
- (BOOL) performKeyEquivalent: (NSEvent*)theEvent
{
return NO;
@ -69,10 +107,11 @@
- (NSPanel*) _createWindow
{
NSPanel *win = [[GormNSMenuWindow alloc]
initWithContentRect: NSZeroRect
initWithContentRect: NSZeroRect
styleMask: /*NSTitledWindowMask/*/NSBorderlessWindowMask
backing: NSBackingStoreBuffered
defer: YES];
backing: NSBackingStoreBuffered
defer: YES];
[win setMenu: self];
[win setLevel: NSSubmenuWindowLevel];
// [win setWorksWhenModal: YES];

View file

@ -137,7 +137,7 @@
*/
m = [GormNSMenu new];
[m addItemWithTitle: @"Open..."
action: @selector(open:)
action: @selector(open:)
keyEquivalent: @"o"];
[m addItemWithTitle: @"New"
action: @selector(new:)
@ -185,13 +185,13 @@
*/
m = [GormNSMenu new];
[m addItemWithTitle: @"Align Left"
action: @selector(alignSelLeft:)
action: @selector(alignLeft:)
keyEquivalent: @""];
[m addItemWithTitle: @"Center"
action: @selector(alignSelCenter:)
action: @selector(alignCenter:)
keyEquivalent: @""];
[m addItemWithTitle: @"Align Right"
action: @selector(alignSelRight:)
action: @selector(alignRight:)
keyEquivalent: @""];
[m addItemWithTitle: @"Show Ruler"
action: @selector(toggleRuler:)
@ -346,13 +346,13 @@
keyEquivalent: @""];
s = [GormNSMenu new];
[s addItemWithTitle: @"Align Left"
action: @selector(alignSelLeft:)
action: @selector(alignLeft:)
keyEquivalent: @""];
[s addItemWithTitle: @"Center"
action: @selector(alignSelCenter:)
action: @selector(alignCenter:)
keyEquivalent: @""];
[s addItemWithTitle: @"Align Right"
action: @selector(alignSelRight:)
action: @selector(alignRight:)
keyEquivalent: @""];
[s addItemWithTitle: @"Show Ruler"
action: @selector(toggleRuler:)

View file

@ -25,7 +25,11 @@ include $(GNUSTEP_MAKEFILES)/common.make
PALETTE_NAME = 2Controls
2Controls_PALETTE_ICON = ControlsPalette
2Controls_OBJC_FILES = main.m inspectors.m
2Controls_OBJC_FILES = \
main.m \
inspectors.m \
GormPopUpButtonEditor.m
2Controls_PRINCIPAL_CLASS = ControlsPalette
2Controls_RESOURCE_FILES = ControlsPalette.tiff \

View file

@ -0,0 +1,137 @@
#import <AppKit/AppKit.h>
#import "../../GormPrivate.h"
#import "../../GormControlEditor.h"
#import "../../GormViewWithSubviewsEditor.h"
#define _EO ((NSPopUpButton *)_editedObject)
@class GormNSPopUpButtonCell;
Class _gormnspopupbuttonCellClass = 0;
@interface GormNSPopUpButton : NSPopUpButton
@end
@implementation GormNSPopUpButton
/*
* Class methods
*/
+ (void) initialize
{
if (self == [GormNSPopUpButton class])
{
// Initial version
[self setVersion: 1];
[self setCellClass: [GormNSPopUpButtonCell class]];
}
}
+ (Class) cellClass
{
return _gormnspopupbuttonCellClass;
}
+ (void) setCellClass: (Class)classId
{
_gormnspopupbuttonCellClass = classId;
}
- (NSString*) editorClassName
{
return @"GormPopUpButtonEditor";
}
@end
@interface GormNSPopUpButtonCell : NSPopUpButtonCell
{
}
@end
@implementation NSPopUpButtonCell (DirtyHack)
- (id) _gormInitTextCell: (NSString *) string
{
return [super initTextCell: string];
}
@end
@implementation GormNSPopUpButtonCell
- (id) initTextCell: (NSString*) stringValue
pullsDown: (BOOL) pullDown
{
[super _gormInitTextCell: stringValue];
_pbcFlags.pullsDown = pullDown;
_pbcFlags.usesItemFromMenu = YES;
_pbcFlags.altersStateOfSelectedItem = YES;
if ([stringValue length] > 0)
{
[self addItemWithTitle: stringValue];
}
_menu = [(id)[NSMenu allocSubstitute] initWithTitle: @""];
[_menu _setOwnedByPopUp: self];
return self;
}
@end
// @interface GormPopUpNSMenu : NSMenu
// - (BOOL)canBecomeMainWindow
// {
// return YES;
// }
// - (BOOL)canBecomeKeyWindow
// {
// return YES;
// }
// - (void) sendEvent: (NSEvent*)theEvent
// {
// NSEventType type;
// type = [theEvent type];
// if (type == NSLeftMouseDown)
// {
// NSLog(@"here");
// if (_f.is_main == YES)
// {
// NSLog(@"already main %@", [NSApp mainWindow]);
// }
// [self makeMainWindow];
// [self makeKeyWindow];
// }
// [super sendEvent: theEvent];
// }
// @end
// @implementation GormPopUpNSMenu
// @end
@interface GormPopUpButtonEditor : GormControlEditor
{
}
@end
@implementation GormPopUpButtonEditor
- (void) mouseDown: (NSEvent *)theEvent
{
if (([theEvent clickCount] == 2) && [parent isOpened])
// double-clicked -> let's edit
{
[[_EO cell]
attachPopUpWithFrame: [_EO bounds]
inView: _editedObject];
NSLog(@"attach down");
[[document openEditorForObject: [[_EO cell] menu]] activate];
}
else
{
[super mouseDown: theEvent];
}
}
@end

View file

@ -817,7 +817,11 @@
{
if (control == typeMatrix)
{
id selectedItem;
[object setPullsDown: [[control selectedCell] tag]];
selectedItem = [object selectedItem];
[object selectItem: nil];
[object selectItem: selectedItem];
}
else if (control == disabledSwitch)
{

View file

@ -26,6 +26,9 @@
#include "../../Gorm.h"
#include "../../GormCustomView.h"
// @class GormPopUpNSMenu;
@class GormNSPopUpButton;
@interface ControlsPalette: IBPalette
{
}
@ -147,7 +150,7 @@
/*******************/
// Popup button
v = [[NSPopUpButton alloc] initWithFrame: NSMakeRect(172, 147, 89, 20)];
v = [[GormNSPopUpButton alloc] initWithFrame: NSMakeRect(172, 147, 89, 20)];
[v addItemWithTitle: @"Item 1"];
[v addItemWithTitle: @"Item 2"];
[v addItemWithTitle: @"Item 3"];

View file

@ -80,8 +80,6 @@ static NSText *_textObject;
*/
- (BOOL) activate
{
NSLog(@"activate");
if ([super activate])
{
if ([_editedObject isKindOfClass: [NSScrollView class]])
@ -402,6 +400,120 @@ static NSText *_textObject;
// return [NSArray arrayWithObject: selected];
// }
- (unsigned) draggingEntered: (id<NSDraggingInfo>)sender
{
return [self draggingUpdated: sender];
}
- (unsigned) draggingUpdated: (id<NSDraggingInfo>)sender
{
NSPasteboard *dragPb;
NSArray *types;
dragPb = [sender draggingPasteboard];
types = [dragPb types];
if ([types containsObject: GormLinkPboardType] == YES)
{
id destination = nil;
NSView *hitView =
[[tableView enclosingScrollView]
hitTest:
[[[tableView enclosingScrollView] superview]
convertPoint: [sender draggingLocation]
fromView: nil]];
if (hitView == [tableView headerView])
{
NSPoint p = [hitView convertPoint: [sender draggingLocation]
fromView: nil];
int columnNumber =
[(NSTableHeaderView*) hitView columnAtPoint: p];
if (columnNumber != -1)
destination = [[tableView tableColumns]
objectAtIndex: columnNumber];
}
if ([hitView isKindOfClass: [NSScroller class]]
|| [hitView isKindOfClass: [NSScrollView class]])
{
destination = _editedObject;
}
if (destination == nil)
destination = tableView;
[NSApp displayConnectionBetween: [NSApp connectSource]
and: destination];
return NSDragOperationLink;
}
else
{
return NSDragOperationNone;
}
}
- (BOOL) performDragOperation: (id<NSDraggingInfo>)sender
{
NSPasteboard *dragPb;
NSArray *types;
dragPb = [sender draggingPasteboard];
types = [dragPb types];
if ([types containsObject: GormLinkPboardType] == YES)
{
id destination = nil;
NSView *hitView =
[[tableView enclosingScrollView]
hitTest:
[[[tableView enclosingScrollView] superview]
convertPoint: [sender draggingLocation]
fromView: nil]];
if (hitView == [tableView headerView])
{
NSPoint p = [hitView convertPoint: [sender draggingLocation]
fromView: nil];
int columnNumber =
[(NSTableHeaderView*) hitView columnAtPoint: p];
if (columnNumber != -1)
destination = [[tableView tableColumns]
objectAtIndex: columnNumber];
}
if ([hitView isKindOfClass: [NSScroller class]]
|| [hitView isKindOfClass: [NSScrollView class]])
{
destination = _editedObject;
}
if (destination == nil)
destination = tableView;
[NSApp displayConnectionBetween: [NSApp connectSource]
and: destination];
[NSApp startConnecting];
return YES;
}
return YES;
}
- (NSWindow *)windowAndRect: (NSRect *)prect
forObject: (id) object
{
if (object == tableView)
{
*prect = [tableView convertRect: [tableView visibleRect]
toView :nil];
return _window;
}
else
{
return [super windowAndRect: prect forObject: object];
}
}
@end

View file

@ -197,6 +197,7 @@ int defaultDateFormatIndex = 3;
id v;
NSNumberFormatter *nf;
NSDateFormatter *df;
NSRect rect;
window = [[NSWindow alloc] initWithContentRect: NSMakeRect(0, 0, 272, 192)
@ -214,22 +215,26 @@ int defaultDateFormatIndex = 3;
v = [[NSScrollView alloc] initWithFrame: NSMakeRect(20, 22, 113,148)];
[v setHasVerticalScroller: YES];
[v setHasHorizontalScroller: NO];
// [v setAutoresizingMask: NSViewHeightSizable|NSViewWidthSizable];
contentSize = [v contentSize];
[v setAutoresizingMask: NSViewHeightSizable | NSViewWidthSizable];
[[v contentView] setAutoresizingMask: NSViewHeightSizable
| NSViewWidthSizable];
[[v contentView] setAutoresizesSubviews:YES];
tv = [[NSTextView alloc] initWithFrame:
NSMakeRect(0,0,contentSize.width, contentSize.height)];
rect = [[v contentView] frame];
tv = [[NSTextView alloc] initWithFrame: rect];
[tv setMinSize: NSMakeSize(0.0, 0.0)];
[tv setMaxSize: NSMakeSize(1.0E7,1.0E7)];
[tv setVerticallyResizable:YES];
[tv setHorizontallyResizable:NO];
[tv setHorizontallyResizable: NO];
[tv setVerticallyResizable: YES];
[tv setAutoresizingMask: NSViewWidthSizable];
[tv setSelectable: YES];
[tv setEditable: YES];
[tv setRichText: YES];
[tv setImportsGraphics: YES];
[[tv textContainer] setContainerSize:contentSize];
[[tv textContainer] setContainerSize:NSMakeSize(rect.size.width,
1e7)];
[[tv textContainer] setWidthTracksTextView:YES];
[v setDocumentView:tv];