mirror of
https://github.com/gnustep/apps-gorm.git
synced 2025-02-24 03:51:22 +00:00
* 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:
parent
4549ec7312
commit
f9ad0e9a14
21 changed files with 1263 additions and 330 deletions
130
Gorm.m
130
Gorm.m
|
@ -206,6 +206,12 @@ NSString *GormLinkPboardType = @"GormLinkPboardType";
|
||||||
NSWindow *win;
|
NSWindow *win;
|
||||||
BOOL edited = NO;
|
BOOL edited = NO;
|
||||||
|
|
||||||
|
if (isTesting == YES)
|
||||||
|
{
|
||||||
|
[self endTesting: sender];
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
while ((win = [enumerator nextObject]) != nil)
|
while ((win = [enumerator nextObject]) != nil)
|
||||||
{
|
{
|
||||||
if ([win isDocumentEdited] == YES)
|
if ([win isDocumentEdited] == YES)
|
||||||
|
@ -347,8 +353,9 @@ NSString *GormLinkPboardType = @"GormLinkPboardType";
|
||||||
|
|
||||||
- (void) displayConnectionBetween: (id)source and: (id)destination
|
- (void) displayConnectionBetween: (id)source and: (id)destination
|
||||||
{
|
{
|
||||||
NSWindow *w;
|
NSWindow *w, *neww;
|
||||||
NSRect r;
|
NSRect r, newr;
|
||||||
|
|
||||||
|
|
||||||
if (source != connectSource)
|
if (source != connectSource)
|
||||||
{
|
{
|
||||||
|
@ -359,38 +366,21 @@ NSString *GormLinkPboardType = @"GormLinkPboardType";
|
||||||
if (w != nil)
|
if (w != nil)
|
||||||
{
|
{
|
||||||
NSView *wv = [[w contentView] superview];
|
NSView *wv = [[w contentView] superview];
|
||||||
|
|
||||||
|
r.origin.x --;
|
||||||
|
r.size.width ++;
|
||||||
|
|
||||||
|
r.size.height ++;
|
||||||
|
|
||||||
/*
|
[w disableFlushWindow];
|
||||||
* 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];
|
|
||||||
[wv displayRect: r];
|
[wv displayRect: r];
|
||||||
[wv unlockFocus];
|
|
||||||
|
[w enableFlushWindow];
|
||||||
[w flushWindow];
|
[w flushWindow];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
connectSource = source;
|
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 (destination != connectDestination)
|
||||||
{
|
{
|
||||||
if (connectDestination != nil)
|
if (connectDestination != nil)
|
||||||
|
@ -404,11 +394,9 @@ NSString *GormLinkPboardType = @"GormLinkPboardType";
|
||||||
/*
|
/*
|
||||||
* Erase image from old location.
|
* Erase image from old location.
|
||||||
*/
|
*/
|
||||||
r.origin.x -= 1.0;
|
r.origin.x --;
|
||||||
r.origin.y += 1.0;
|
r.size.width ++;
|
||||||
r.size = [targetImage size];
|
r.size.height ++;
|
||||||
r.size.width += 2.0;
|
|
||||||
r.size.height += 2.0;
|
|
||||||
|
|
||||||
[wv lockFocus];
|
[wv lockFocus];
|
||||||
[wv displayRect: r];
|
[wv displayRect: r];
|
||||||
|
@ -418,7 +406,27 @@ NSString *GormLinkPboardType = @"GormLinkPboardType";
|
||||||
}
|
}
|
||||||
connectDestination = destination;
|
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
|
w = [[self activeDocument] windowAndRect: &r
|
||||||
forObject: connectDestination];
|
forObject: connectDestination];
|
||||||
|
@ -426,9 +434,38 @@ NSString *GormLinkPboardType = @"GormLinkPboardType";
|
||||||
{
|
{
|
||||||
NSView *wv = [[w contentView] superview];
|
NSView *wv = [[w contentView] superview];
|
||||||
|
|
||||||
|
r.origin.x += 3;
|
||||||
|
r.origin.y += 2;
|
||||||
|
r.size.width -= 5;
|
||||||
|
r.size.height -= 5;
|
||||||
[wv lockFocus];
|
[wv lockFocus];
|
||||||
|
[[NSColor purpleColor] set];
|
||||||
|
NSFrameRectWithWidth(r, 2);
|
||||||
|
|
||||||
|
r.origin.x += [targetImage size].width;
|
||||||
[targetImage compositeToPoint: r.origin
|
[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];
|
[wv unlockFocus];
|
||||||
[w flushWindow];
|
[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
|
- (id) endTesting: (id)sender
|
||||||
{
|
{
|
||||||
if (isTesting == NO)
|
if (isTesting == NO)
|
||||||
|
@ -1136,6 +1186,12 @@ NSLog(@"StartupTime %f", [startDate timeIntervalSinceNow]);
|
||||||
intoClassName: @"NSWindow"];
|
intoClassName: @"NSWindow"];
|
||||||
[archiver encodeClassName: @"GormNSMenu"
|
[archiver encodeClassName: @"GormNSMenu"
|
||||||
intoClassName: @"NSMenu"];
|
intoClassName: @"NSMenu"];
|
||||||
|
[archiver encodeClassName: @"GormNSPopUpButton"
|
||||||
|
intoClassName: @"NSPopUpButton"];
|
||||||
|
[archiver encodeClassName: @"GormNSPopUpButtonCell"
|
||||||
|
intoClassName: @"NSPopUpButtonCell"];
|
||||||
|
[archiver encodeClassName: @"GormCustomView"
|
||||||
|
intoClassName: @"GormTestCustomView"];
|
||||||
[archiver encodeRootObject: a];
|
[archiver encodeRootObject: a];
|
||||||
d = RETAIN([archiver archiverData]);
|
d = RETAIN([archiver archiverData]);
|
||||||
[a endArchiving];
|
[a endArchiving];
|
||||||
|
@ -1172,7 +1228,7 @@ NSLog(@"StartupTime %f", [startDate timeIntervalSinceNow]);
|
||||||
|
|
||||||
testMenu = [[NSMenu alloc] initWithTitle: @"Test"];
|
testMenu = [[NSMenu alloc] initWithTitle: @"Test"];
|
||||||
[testMenu addItemWithTitle: @"Quit"
|
[testMenu addItemWithTitle: @"Quit"
|
||||||
action: @selector(endTesting:)
|
action: @selector(deferredEndTesting:)
|
||||||
keyEquivalent: @"q"];
|
keyEquivalent: @"q"];
|
||||||
[self setMainMenu: testMenu];
|
[self setMainMenu: testMenu];
|
||||||
RELEASE(testMenu);
|
RELEASE(testMenu);
|
||||||
|
@ -1185,12 +1241,12 @@ NSLog(@"StartupTime %f", [startDate timeIntervalSinceNow]);
|
||||||
item = [testMenu itemWithTitle: @"Quit"];
|
item = [testMenu itemWithTitle: @"Quit"];
|
||||||
if (item != nil)
|
if (item != nil)
|
||||||
{
|
{
|
||||||
[item setAction: @selector(endTesting:)];
|
[item setAction: @selector(deferredEndTesting:)];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[testMenu addItemWithTitle: @"Quit"
|
[testMenu addItemWithTitle: @"Quit"
|
||||||
action: @selector(endTesting:)
|
action: @selector(deferredEndTesting:)
|
||||||
keyEquivalent: @"q"];
|
keyEquivalent: @"q"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
408
GormBoxEditor.m
408
GormBoxEditor.m
|
@ -434,236 +434,248 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
- (unsigned) draggingEntered: (id<NSDraggingInfo>)sender
|
// - (unsigned) draggingEntered: (id<NSDraggingInfo>)sender
|
||||||
{
|
// {
|
||||||
NSRect rect = [[_EO contentView] bounds];
|
// NSRect rect = [[_EO contentView] bounds];
|
||||||
NSPoint loc = [sender draggingLocation];
|
// NSPoint loc = [sender draggingLocation];
|
||||||
loc = [[_EO contentView]
|
// NSPasteboard *dragPb;
|
||||||
convertPoint: loc fromView: nil];
|
// NSArray *types;
|
||||||
|
|
||||||
|
// dragPb = [sender draggingPasteboard];
|
||||||
|
// types = [dragPb types];
|
||||||
|
// loc = [[_EO contentView]
|
||||||
|
// convertPoint: loc fromView: nil];
|
||||||
|
|
||||||
if (NSMouseInRect(loc, [[_EO contentView] bounds], NO) == NO)
|
// if ([types containsObject: GormLinkPboardType] == YES)
|
||||||
{
|
// {
|
||||||
return NSDragOperationNone;
|
// [NSApp displayConnectionBetween: [NSApp connectSource]
|
||||||
}
|
// and: _editedObject];
|
||||||
else
|
// NSLog(@"I said Yes !");
|
||||||
{
|
// return NSDragOperationLink;
|
||||||
rect.origin.x += 2;
|
// }
|
||||||
rect.origin.y += 2;
|
// if (NSMouseInRect(loc, [[_EO contentView] bounds], NO) == NO)
|
||||||
rect.size.width -= 4;
|
// {
|
||||||
rect.size.height -= 4;
|
// 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];
|
// [[NSColor darkGrayColor] set];
|
||||||
NSFrameRectWithWidth(rect, 2);
|
// NSFrameRectWithWidth(rect, 2);
|
||||||
|
|
||||||
[[_EO contentView] unlockFocus];
|
// [[_EO contentView] unlockFocus];
|
||||||
[[self window] flushWindow];
|
// [[self window] flushWindow];
|
||||||
return NSDragOperationCopy;
|
// return NSDragOperationCopy;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
- (void) draggingExited: (id<NSDraggingInfo>)sender
|
// - (void) draggingExited: (id<NSDraggingInfo>)sender
|
||||||
{
|
// {
|
||||||
NSRect rect = [[_EO contentView] bounds];
|
// NSRect rect = [[_EO contentView] bounds];
|
||||||
rect.origin.x += 2;
|
// rect.origin.x += 2;
|
||||||
rect.origin.y += 2;
|
// rect.origin.y += 2;
|
||||||
rect.size.width -= 4;
|
// rect.size.width -= 4;
|
||||||
rect.size.height -= 4;
|
// rect.size.height -= 4;
|
||||||
|
|
||||||
rect.origin.x --;
|
// rect.origin.x --;
|
||||||
rect.size.width ++;
|
// rect.size.width ++;
|
||||||
rect.size.height ++;
|
// rect.size.height ++;
|
||||||
|
|
||||||
[[self window] disableFlushWindow];
|
// [[self window] disableFlushWindow];
|
||||||
[self displayRect:
|
// [self displayRect:
|
||||||
[[_EO contentView] convertRect: rect
|
// [[_EO contentView] convertRect: rect
|
||||||
toView: self]];
|
// toView: self]];
|
||||||
[[self window] enableFlushWindow];
|
// [[self window] enableFlushWindow];
|
||||||
[[self window] flushWindow];
|
// [[self window] flushWindow];
|
||||||
}
|
// }
|
||||||
|
|
||||||
- (unsigned int) draggingUpdated: (id<NSDraggingInfo>)sender
|
// - (unsigned int) draggingUpdated: (id<NSDraggingInfo>)sender
|
||||||
{
|
// {
|
||||||
NSPoint loc = [sender draggingLocation];
|
// NSPoint loc = [sender draggingLocation];
|
||||||
NSRect rect = [[_EO contentView] bounds];
|
// NSRect rect = [[_EO contentView] bounds];
|
||||||
loc = [[_EO contentView]
|
// loc = [[_EO contentView]
|
||||||
convertPoint: loc fromView: nil];
|
// convertPoint: loc fromView: nil];
|
||||||
|
|
||||||
rect.origin.x += 2;
|
// rect.origin.x += 2;
|
||||||
rect.origin.y += 2;
|
// rect.origin.y += 2;
|
||||||
rect.size.width -= 4;
|
// rect.size.width -= 4;
|
||||||
rect.size.height -= 4;
|
// rect.size.height -= 4;
|
||||||
|
|
||||||
if (NSMouseInRect(loc, [[_EO contentView] bounds], NO) == NO)
|
// if (NSMouseInRect(loc, [[_EO contentView] bounds], NO) == NO)
|
||||||
{
|
// {
|
||||||
[[self window] disableFlushWindow];
|
// [[self window] disableFlushWindow];
|
||||||
rect.origin.x --;
|
// rect.origin.x --;
|
||||||
rect.size.width ++;
|
// rect.size.width ++;
|
||||||
rect.size.height ++;
|
// rect.size.height ++;
|
||||||
[self displayRect:
|
// [self displayRect:
|
||||||
[[_EO contentView] convertRect: rect
|
// [[_EO contentView] convertRect: rect
|
||||||
toView: self]];
|
// toView: self]];
|
||||||
[[self window] enableFlushWindow];
|
// [[self window] enableFlushWindow];
|
||||||
[[self window] flushWindow];
|
// [[self window] flushWindow];
|
||||||
return NSDragOperationNone;
|
// return NSDragOperationNone;
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
[[_EO contentView] lockFocus];
|
// [[_EO contentView] lockFocus];
|
||||||
|
|
||||||
[[NSColor darkGrayColor] set];
|
// [[NSColor darkGrayColor] set];
|
||||||
NSFrameRectWithWidth(rect, 2);
|
// NSFrameRectWithWidth(rect, 2);
|
||||||
|
|
||||||
[[_EO contentView] unlockFocus];
|
// [[_EO contentView] unlockFocus];
|
||||||
[[self window] flushWindow];
|
// [[self window] flushWindow];
|
||||||
return NSDragOperationCopy;
|
// return NSDragOperationCopy;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
- (BOOL) prepareForDragOperation: (id<NSDraggingInfo>)sender
|
// - (BOOL) prepareForDragOperation: (id<NSDraggingInfo>)sender
|
||||||
{
|
// {
|
||||||
NSString *dragType;
|
// NSString *dragType;
|
||||||
NSArray *types;
|
// NSArray *types;
|
||||||
NSPasteboard *dragPb;
|
// 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)
|
// if ([types containsObject: IBViewPboardType] == YES)
|
||||||
{
|
// {
|
||||||
dragType = IBViewPboardType;
|
// dragType = IBViewPboardType;
|
||||||
}
|
// }
|
||||||
else if ([types containsObject: GormLinkPboardType] == YES)
|
// else if ([types containsObject: GormLinkPboardType] == YES)
|
||||||
{
|
// {
|
||||||
dragType = GormLinkPboardType;
|
// dragType = GormLinkPboardType;
|
||||||
}
|
// }
|
||||||
else if ([types containsObject: IBFormatterPboardType] == YES)
|
// else if ([types containsObject: IBFormatterPboardType] == YES)
|
||||||
{
|
// {
|
||||||
dragType = IBFormatterPboardType;
|
// dragType = IBFormatterPboardType;
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
dragType = nil;
|
// dragType = nil;
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (dragType == IBViewPboardType)
|
// if (dragType == IBViewPboardType)
|
||||||
{
|
// {
|
||||||
/*
|
// /*
|
||||||
* We can accept views dropped anywhere.
|
// * We can accept views dropped anywhere.
|
||||||
*/
|
// */
|
||||||
NSPoint loc = [sender draggingLocation];
|
// NSPoint loc = [sender draggingLocation];
|
||||||
loc = [[_EO contentView]
|
// loc = [[_EO contentView]
|
||||||
convertPoint: loc fromView: nil];
|
// convertPoint: loc fromView: nil];
|
||||||
if (NSMouseInRect(loc, [_EO bounds], NO) == NO)
|
// if (NSMouseInRect(loc, [_EO bounds], NO) == NO)
|
||||||
{
|
// {
|
||||||
return NO;
|
// return NO;
|
||||||
}
|
// }
|
||||||
|
|
||||||
return YES;
|
// return YES;
|
||||||
}
|
// }
|
||||||
|
|
||||||
return NO;
|
// return NO;
|
||||||
}
|
// }
|
||||||
|
|
||||||
- (BOOL) performDragOperation: (id<NSDraggingInfo>)sender
|
// - (BOOL) performDragOperation: (id<NSDraggingInfo>)sender
|
||||||
{
|
// {
|
||||||
NSString *dragType;
|
// NSString *dragType;
|
||||||
NSPasteboard *dragPb;
|
// NSPasteboard *dragPb;
|
||||||
NSArray *types;
|
// NSArray *types;
|
||||||
|
|
||||||
dragPb = [sender draggingPasteboard];
|
// dragPb = [sender draggingPasteboard];
|
||||||
|
|
||||||
types = [dragPb types];
|
// types = [dragPb types];
|
||||||
|
|
||||||
if ([types containsObject: IBViewPboardType] == YES)
|
// if ([types containsObject: IBViewPboardType] == YES)
|
||||||
{
|
// {
|
||||||
dragType = IBViewPboardType;
|
// dragType = IBViewPboardType;
|
||||||
}
|
// }
|
||||||
else if ([types containsObject: GormLinkPboardType] == YES)
|
// else if ([types containsObject: GormLinkPboardType] == YES)
|
||||||
{
|
// {
|
||||||
dragType = GormLinkPboardType;
|
// dragType = GormLinkPboardType;
|
||||||
}
|
// }
|
||||||
else if ([types containsObject: IBFormatterPboardType] == YES)
|
// else if ([types containsObject: IBFormatterPboardType] == YES)
|
||||||
{
|
// {
|
||||||
dragType = IBFormatterPboardType;
|
// dragType = IBFormatterPboardType;
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
dragType = nil;
|
// dragType = nil;
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (dragType == IBViewPboardType)
|
// if (dragType == IBViewPboardType)
|
||||||
{
|
// {
|
||||||
NSPoint loc = [sender draggingLocation];
|
// NSPoint loc = [sender draggingLocation];
|
||||||
NSArray *views;
|
// NSArray *views;
|
||||||
// NSArray *array = [NSMutableArray array];
|
// // NSArray *array = [NSMutableArray array];
|
||||||
NSEnumerator *enumerator;
|
// NSEnumerator *enumerator;
|
||||||
NSView *sub;
|
// NSView *sub;
|
||||||
|
|
||||||
/*
|
// /*
|
||||||
if (opened != YES)
|
// if (opened != YES)
|
||||||
{
|
// {
|
||||||
NSLog(@"make ourself the editor");
|
// NSLog(@"make ourself the editor");
|
||||||
}
|
// }
|
||||||
else if (openedSubeditor != nil)
|
// else if (openedSubeditor != nil)
|
||||||
{
|
// {
|
||||||
NSLog(@"close our subeditors");
|
// NSLog(@"close our subeditors");
|
||||||
}
|
// }
|
||||||
*/
|
// */
|
||||||
|
|
||||||
/*
|
// /*
|
||||||
* Ask the document to get the dragged views from the pasteboard and add
|
// * Ask the document to get the dragged views from the pasteboard and add
|
||||||
* them to it's collection of known objects.
|
// * them to it's collection of known objects.
|
||||||
*/
|
// */
|
||||||
views = [document pasteType: IBViewPboardType
|
// views = [document pasteType: IBViewPboardType
|
||||||
fromPasteboard: dragPb
|
// fromPasteboard: dragPb
|
||||||
parent: _EO];
|
// parent: _EO];
|
||||||
/*
|
// /*
|
||||||
* Now make all the views subviews of ourself, setting their origin to
|
// * Now make all the views subviews of ourself, setting their origin to
|
||||||
* be the point at which they were dropped (converted from window
|
// * be the point at which they were dropped (converted from window
|
||||||
* coordinates to our own coordinates).
|
// * coordinates to our own coordinates).
|
||||||
*/
|
// */
|
||||||
loc = [[_EO contentView]
|
// loc = [[_EO contentView]
|
||||||
convertPoint: loc fromView: nil];
|
// convertPoint: loc fromView: nil];
|
||||||
if (NSMouseInRect(loc, [_EO bounds], NO) == NO)
|
// if (NSMouseInRect(loc, [_EO bounds], NO) == NO)
|
||||||
{
|
// {
|
||||||
// Dropped outside our view frame
|
// // Dropped outside our view frame
|
||||||
NSLog(@"Dropped outside current edit view");
|
// NSLog(@"Dropped outside current edit view");
|
||||||
dragType = nil;
|
// dragType = nil;
|
||||||
return NO;
|
// return NO;
|
||||||
}
|
// }
|
||||||
enumerator = [views objectEnumerator];
|
// enumerator = [views objectEnumerator];
|
||||||
while ((sub = [enumerator nextObject]) != nil)
|
// while ((sub = [enumerator nextObject]) != nil)
|
||||||
{
|
// {
|
||||||
NSRect rect = [sub frame];
|
// NSRect rect = [sub frame];
|
||||||
|
|
||||||
rect.origin = [[_EO contentView]
|
// rect.origin = [[_EO contentView]
|
||||||
convertPoint: [sender draggedImageLocation]
|
// convertPoint: [sender draggedImageLocation]
|
||||||
fromView: nil];
|
// fromView: nil];
|
||||||
rect.origin.x = (int) rect.origin.x;
|
// rect.origin.x = (int) rect.origin.x;
|
||||||
rect.origin.y = (int) rect.origin.y;
|
// rect.origin.y = (int) rect.origin.y;
|
||||||
rect.size.width = (int) rect.size.width;
|
// rect.size.width = (int) rect.size.width;
|
||||||
rect.size.height = (int) rect.size.height;
|
// rect.size.height = (int) rect.size.height;
|
||||||
[sub setFrame: rect];
|
// [sub setFrame: rect];
|
||||||
|
|
||||||
[[_EO contentView] addSubview: sub];
|
// [[_EO contentView] addSubview: sub];
|
||||||
|
|
||||||
[self selectObjects:
|
// [self selectObjects:
|
||||||
[NSArray arrayWithObject:
|
// [NSArray arrayWithObject:
|
||||||
[document editorForObject: sub
|
// [document editorForObject: sub
|
||||||
inEditor: self
|
// inEditor: self
|
||||||
create: YES]]];
|
// create: YES]]];
|
||||||
}
|
// }
|
||||||
// FIXME we should maybe open ourself
|
// // FIXME we should maybe open ourself
|
||||||
}
|
// }
|
||||||
|
|
||||||
return YES;
|
// return YES;
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
// - (void) pasteInSelection
|
// - (void) pasteInSelection
|
||||||
|
|
|
@ -29,6 +29,8 @@
|
||||||
#import "GormButtonEditor.h"
|
#import "GormButtonEditor.h"
|
||||||
|
|
||||||
#import "GormViewWithSubviewsEditor.h"
|
#import "GormViewWithSubviewsEditor.h"
|
||||||
|
#import "Gorm.h"
|
||||||
|
|
||||||
|
|
||||||
#define _EO ((NSButton *)_editedObject)
|
#define _EO ((NSButton *)_editedObject)
|
||||||
|
|
||||||
|
@ -297,36 +299,283 @@
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
static BOOL done_editing;
|
||||||
|
static NSRect oldFrame;
|
||||||
|
|
||||||
@implementation GormButtonEditor
|
@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
|
- (void) mouseDown: (NSEvent*)theEvent
|
||||||
{
|
{
|
||||||
if (([theEvent clickCount] == 2) && [parent isOpened])
|
if (([theEvent clickCount] == 2) && [parent isOpened])
|
||||||
// double-clicked -> let's edit
|
// double-clicked -> let's edit
|
||||||
{
|
{
|
||||||
NSTextField *tf =
|
// NSTextField *tf =
|
||||||
[[NSTextField alloc] initWithFrame: [self bounds]];
|
// [[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]
|
NSRect frame = [[_EO cell]
|
||||||
gormTitleRectForFrame: [_EO frame]
|
gormTitleRectForFrame: [_EO frame]
|
||||||
inView: _EO];
|
inView: _EO];
|
||||||
frame.origin.y -= 2;
|
// frame.origin.y -= 2;
|
||||||
frame.size.height += 4;
|
// frame.size.height = 2;
|
||||||
[tf setFrame: frame];
|
NSTextView *tv = [self startEditingInFrame: frame];
|
||||||
[tf setEditable: YES];
|
[[[self window] contentView] addSubview: tv];
|
||||||
[tf setBezeled: NO];
|
[tv setText: [_EO stringValue]];
|
||||||
[tf setBordered: YES];
|
[tv setAlignment: [_EO alignment]];
|
||||||
[tf setAlignment: [_EO alignment]];
|
[tv setFont: [_EO font]];
|
||||||
[tf setFont: [_EO font]];
|
[[self window] display];
|
||||||
[self addSubview: tf];
|
[[self window] makeFirstResponder: tv];
|
||||||
[tf setStringValue: [_EO stringValue]];
|
|
||||||
[self editTextField: tf
|
[tv mouseDown: theEvent];
|
||||||
withEvent: theEvent];
|
|
||||||
[_EO setStringValue: [tf stringValue]];
|
|
||||||
[tf removeFromSuperview];
|
|
||||||
RELEASE(tf);
|
|
||||||
[[NSNotificationCenter defaultCenter]
|
|
||||||
postNotificationName: IBSelectionChangedNotification
|
|
||||||
object: parent];
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,6 +27,8 @@
|
||||||
#include <AppKit/NSGraphics.h>
|
#include <AppKit/NSGraphics.h>
|
||||||
#include <AppKit/NSFont.h>
|
#include <AppKit/NSFont.h>
|
||||||
|
|
||||||
|
#import <AppKit/NSNibLoading.h>
|
||||||
|
|
||||||
@class GSCustomView;
|
@class GSCustomView;
|
||||||
|
|
||||||
@implementation GormCustomView
|
@implementation GormCustomView
|
||||||
|
@ -61,10 +63,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (Class) classForCoder
|
// - (Class) classForCoder
|
||||||
{
|
// {
|
||||||
return [GSCustomView class];
|
// return [GSCustomView class];
|
||||||
}
|
// }
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This needs to be coded like a GSNibItem. How do we make sure this
|
* This needs to be coded like a GSNibItem. How do we make sure this
|
||||||
|
@ -117,3 +119,51 @@
|
||||||
|
|
||||||
@end
|
@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
|
||||||
|
|
||||||
|
|
|
@ -274,7 +274,6 @@ static NSImage *classesImage = nil;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NSString *name;
|
NSString *name;
|
||||||
|
|
||||||
obj = [con source];
|
obj = [con source];
|
||||||
name = [self nameForObject: obj];
|
name = [self nameForObject: obj];
|
||||||
[con setSource: name];
|
[con setSource: name];
|
||||||
|
@ -989,7 +988,6 @@ static NSImage *classesImage = nil;
|
||||||
while ((con = [enumerator nextObject]) != nil)
|
while ((con = [enumerator nextObject]) != nil)
|
||||||
{
|
{
|
||||||
NSString *name;
|
NSString *name;
|
||||||
|
|
||||||
name = (NSString*)[con source];
|
name = (NSString*)[con source];
|
||||||
obj = [self objectForName: name];
|
obj = [self objectForName: name];
|
||||||
[con setSource: obj];
|
[con setSource: obj];
|
||||||
|
@ -1005,7 +1003,8 @@ static NSImage *classesImage = nil;
|
||||||
enumerator = [savedEditors objectEnumerator];
|
enumerator = [savedEditors objectEnumerator];
|
||||||
while ((con = [enumerator nextObject]) != nil)
|
while ((con = [enumerator nextObject]) != nil)
|
||||||
{
|
{
|
||||||
[[con destination] activate];
|
if ([[con source] isKindOfClass: [NSView class]] == NO)
|
||||||
|
[[con destination] activate];
|
||||||
}
|
}
|
||||||
[savedEditors removeAllObjects];
|
[savedEditors removeAllObjects];
|
||||||
}
|
}
|
||||||
|
@ -1465,6 +1464,8 @@ static NSImage *classesImage = nil;
|
||||||
[u decodeClassName: @"NSBrowser" asClassName: @"GormNSBrowser"];
|
[u decodeClassName: @"NSBrowser" asClassName: @"GormNSBrowser"];
|
||||||
[u decodeClassName: @"NSTableView" asClassName: @"GormNSTableView"];
|
[u decodeClassName: @"NSTableView" asClassName: @"GormNSTableView"];
|
||||||
[u decodeClassName: @"NSOutlineView" asClassName: @"GormNSOutlineView"];
|
[u decodeClassName: @"NSOutlineView" asClassName: @"GormNSOutlineView"];
|
||||||
|
[u decodeClassName: @"NSPopUpButton" asClassName: @"GormNSPopUpButton"];
|
||||||
|
[u decodeClassName: @"NSPopUpButtonCell" asClassName: @"GormNSPopUpButtonCell"];
|
||||||
|
|
||||||
c = [u decodeObject];
|
c = [u decodeObject];
|
||||||
if (c == nil || [c isKindOfClass: [GSNibContainer class]] == NO)
|
if (c == nil || [c isKindOfClass: [GSNibContainer class]] == NO)
|
||||||
|
@ -2043,6 +2044,10 @@ static NSImage *classesImage = nil;
|
||||||
intoClassName: @"NSTableView"];
|
intoClassName: @"NSTableView"];
|
||||||
[archiver encodeClassName: @"GormNSOutlineView"
|
[archiver encodeClassName: @"GormNSOutlineView"
|
||||||
intoClassName: @"NSOutlineView"];
|
intoClassName: @"NSOutlineView"];
|
||||||
|
[archiver encodeClassName: @"GormNSPopUpButton"
|
||||||
|
intoClassName: @"NSPopUpButton"];
|
||||||
|
[archiver encodeClassName: @"GormNSPopUpButtonCell"
|
||||||
|
intoClassName: @"NSPopUpButtonCell"];
|
||||||
[archiver encodeRootObject: self];
|
[archiver encodeRootObject: self];
|
||||||
archiveResult = [archiverData writeToFile: documentPath atomically: YES];
|
archiveResult = [archiverData writeToFile: documentPath atomically: YES];
|
||||||
//archiveResult = [NSArchiver archiveRootObject: self toFile: documentPath];
|
//archiveResult = [NSArchiver archiveRootObject: self toFile: documentPath];
|
||||||
|
@ -2180,7 +2185,7 @@ static NSImage *classesImage = nil;
|
||||||
else if ([editor respondsToSelector:
|
else if ([editor respondsToSelector:
|
||||||
@selector(windowAndRect:forObject:)])
|
@selector(windowAndRect:forObject:)])
|
||||||
{
|
{
|
||||||
NSLog(@"temp != nil");
|
// NSLog(@"temp != nil");
|
||||||
return [editor windowAndRect: r forObject: object];
|
return [editor windowAndRect: r forObject: object];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2210,7 +2215,7 @@ static NSImage *classesImage = nil;
|
||||||
|
|
||||||
*r = [th convertRect: [th headerRectOfColumn: index]
|
*r = [th convertRect: [th headerRectOfColumn: index]
|
||||||
toView: nil];
|
toView: nil];
|
||||||
NSLog(@"%@", NSStringFromRect(*r));
|
// NSLog(@"%@", NSStringFromRect(*r));
|
||||||
return [th window];
|
return [th window];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -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
|
- (BOOL) browser: (NSBrowser*)sender
|
||||||
selectCellWithString: (NSString*)title
|
selectCellWithString: (NSString*)title
|
||||||
inColumn: (int)col
|
inColumn: (int)col
|
||||||
|
@ -642,6 +659,7 @@ selectCellWithString: (NSString*)title
|
||||||
unsigned numConnectors = [connectors count];
|
unsigned numConnectors = [connectors count];
|
||||||
unsigned index;
|
unsigned index;
|
||||||
|
|
||||||
|
|
||||||
if (sender == newBrowser)
|
if (sender == newBrowser)
|
||||||
{
|
{
|
||||||
if (col == 0)
|
if (col == 0)
|
||||||
|
@ -651,6 +669,7 @@ selectCellWithString: (NSString*)title
|
||||||
id con = nil;
|
id con = nil;
|
||||||
NSString *action;
|
NSString *action;
|
||||||
|
|
||||||
|
|
||||||
for (index = 0; index < numConnectors; index++)
|
for (index = 0; index < numConnectors; index++)
|
||||||
{
|
{
|
||||||
con = [connectors objectAtIndex: index];
|
con = [connectors objectAtIndex: index];
|
||||||
|
@ -676,17 +695,17 @@ selectCellWithString: (NSString*)title
|
||||||
AUTORELEASE(con);
|
AUTORELEASE(con);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (currentConnector != con)
|
if (currentConnector != con)
|
||||||
{
|
{
|
||||||
ASSIGN(currentConnector, con);
|
ASSIGN(currentConnector, con);
|
||||||
[newBrowser setLastColumn: 0];
|
// [newBrowser setLastColumn: 0];
|
||||||
}
|
}
|
||||||
action = [con label];
|
action = [con label];
|
||||||
if (action != nil)
|
if (action != nil)
|
||||||
{
|
{
|
||||||
[newBrowser selectRow: [actions indexOfObject: action]
|
[newBrowser selectRow: [actions indexOfObject: action]
|
||||||
inColumn: 1];
|
inColumn: 1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -901,6 +920,8 @@ selectCellWithString: (NSString*)title
|
||||||
[newBrowser setAllowsMultipleSelection: NO];
|
[newBrowser setAllowsMultipleSelection: NO];
|
||||||
[newBrowser setHasHorizontalScroller: NO];
|
[newBrowser setHasHorizontalScroller: NO];
|
||||||
[newBrowser setDelegate: self];
|
[newBrowser setDelegate: self];
|
||||||
|
[newBrowser setTarget: self];
|
||||||
|
[newBrowser setAction: @selector(_internalCall:)];
|
||||||
|
|
||||||
[split addSubview: newBrowser];
|
[split addSubview: newBrowser];
|
||||||
RELEASE(newBrowser);
|
RELEASE(newBrowser);
|
||||||
|
@ -912,6 +933,8 @@ selectCellWithString: (NSString*)title
|
||||||
[oldBrowser setAllowsMultipleSelection: NO];
|
[oldBrowser setAllowsMultipleSelection: NO];
|
||||||
[oldBrowser setHasHorizontalScroller: NO];
|
[oldBrowser setHasHorizontalScroller: NO];
|
||||||
[oldBrowser setDelegate: self];
|
[oldBrowser setDelegate: self];
|
||||||
|
[newBrowser setTarget: self];
|
||||||
|
[newBrowser setAction: @selector(_internalCall:)];
|
||||||
|
|
||||||
[split addSubview: oldBrowser];
|
[split addSubview: oldBrowser];
|
||||||
RELEASE(oldBrowser);
|
RELEASE(oldBrowser);
|
||||||
|
|
|
@ -320,7 +320,7 @@
|
||||||
if ([parent isOpened] == NO)
|
if ([parent isOpened] == NO)
|
||||||
{
|
{
|
||||||
NSDebugLog(@"md %@ calling my parent %@", self, parent);
|
NSDebugLog(@"md %@ calling my parent %@", self, parent);
|
||||||
[super mouseDown: theEvent];
|
[parent mouseDown: theEvent];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -534,8 +534,18 @@
|
||||||
{
|
{
|
||||||
NSRect rect = [_editedObject bounds];
|
NSRect rect = [_editedObject bounds];
|
||||||
NSPoint loc = [sender draggingLocation];
|
NSPoint loc = [sender draggingLocation];
|
||||||
|
NSPasteboard *dragPb;
|
||||||
|
NSArray *types;
|
||||||
|
|
||||||
|
dragPb = [sender draggingPasteboard];
|
||||||
|
types = [dragPb types];
|
||||||
loc = [_editedObject convertPoint: loc fromView: nil];
|
loc = [_editedObject convertPoint: loc fromView: nil];
|
||||||
|
|
||||||
|
if ([types containsObject: GormLinkPboardType] == YES)
|
||||||
|
{
|
||||||
|
return [parent draggingEntered: sender];
|
||||||
|
}
|
||||||
|
|
||||||
if (NSMouseInRect(loc, [_editedObject bounds], NO) == NO)
|
if (NSMouseInRect(loc, [_editedObject bounds], NO) == NO)
|
||||||
{
|
{
|
||||||
return NSDragOperationNone;
|
return NSDragOperationNone;
|
||||||
|
@ -560,6 +570,18 @@
|
||||||
|
|
||||||
- (void) draggingExited: (id<NSDraggingInfo>)sender
|
- (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];
|
NSRect rect = [_editedObject bounds];
|
||||||
rect.origin.x += 3;
|
rect.origin.x += 3;
|
||||||
rect.origin.y += 2;
|
rect.origin.y += 2;
|
||||||
|
@ -582,9 +604,19 @@
|
||||||
{
|
{
|
||||||
NSPoint loc = [sender draggingLocation];
|
NSPoint loc = [sender draggingLocation];
|
||||||
NSRect rect = [_editedObject bounds];
|
NSRect rect = [_editedObject bounds];
|
||||||
|
NSPasteboard *dragPb;
|
||||||
|
NSArray *types;
|
||||||
|
|
||||||
|
dragPb = [sender draggingPasteboard];
|
||||||
|
types = [dragPb types];
|
||||||
loc = [_editedObject
|
loc = [_editedObject
|
||||||
convertPoint: loc fromView: nil];
|
convertPoint: loc fromView: nil];
|
||||||
|
|
||||||
|
if ([types containsObject: GormLinkPboardType] == YES)
|
||||||
|
{
|
||||||
|
return [parent draggingUpdated: sender];
|
||||||
|
}
|
||||||
|
|
||||||
rect.origin.x += 3;
|
rect.origin.x += 3;
|
||||||
rect.origin.y += 2;
|
rect.origin.y += 2;
|
||||||
rect.size.width -= 5;
|
rect.size.width -= 5;
|
||||||
|
@ -636,6 +668,7 @@
|
||||||
else if ([types containsObject: GormLinkPboardType] == YES)
|
else if ([types containsObject: GormLinkPboardType] == YES)
|
||||||
{
|
{
|
||||||
dragType = GormLinkPboardType;
|
dragType = GormLinkPboardType;
|
||||||
|
return [parent prepareForDragOperation: sender];
|
||||||
}
|
}
|
||||||
else if ([types containsObject: IBFormatterPboardType] == YES)
|
else if ([types containsObject: IBFormatterPboardType] == YES)
|
||||||
{
|
{
|
||||||
|
|
|
@ -251,7 +251,7 @@ static NSMapTable *docMap = 0;
|
||||||
}
|
}
|
||||||
if (obj == [NSApp connectSource])
|
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];
|
[NSApp displayConnectionBetween: [NSApp connectSource] and: obj];
|
||||||
if (obj != nil)
|
if (obj != nil)
|
||||||
|
@ -260,12 +260,12 @@ static NSMapTable *docMap = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return 0;
|
return NSDragOperationNone;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return 0;
|
return NSDragOperationNone;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -545,7 +545,7 @@ static NSMapTable *docMap = 0;
|
||||||
/*
|
/*
|
||||||
* Adjust to image area.
|
* Adjust to image area.
|
||||||
*/
|
*/
|
||||||
rect.size.width -= 15;
|
// rect.size.width -= 15;
|
||||||
rect.size.height -= 15;
|
rect.size.height -= 15;
|
||||||
rect = [self convertRect: rect toView: nil];
|
rect = [self convertRect: rect toView: nil];
|
||||||
return rect;
|
return rect;
|
||||||
|
|
|
@ -288,7 +288,7 @@ static BOOL currently_displaying = NO;
|
||||||
|
|
||||||
|
|
||||||
- (GormPlacementInfo *) initializeResizingInFrame: (NSView *)view
|
- (GormPlacementInfo *) initializeResizingInFrame: (NSView *)view
|
||||||
withKnob: (IBKnobPosition) knob
|
withKnob: (IBKnobPosition) knob
|
||||||
{
|
{
|
||||||
GormPlacementInfo *gip;
|
GormPlacementInfo *gip;
|
||||||
gip = [[GormPlacementInfo alloc] init];
|
gip = [[GormPlacementInfo alloc] init];
|
||||||
|
@ -802,9 +802,6 @@ static BOOL currently_displaying = NO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
- (NSRect) _displayMovingFrameWithHint: (NSRect) frame
|
- (NSRect) _displayMovingFrameWithHint: (NSRect) frame
|
||||||
andPlacementInfo: (GormPlacementInfo*)gpi
|
andPlacementInfo: (GormPlacementInfo*)gpi
|
||||||
{
|
{
|
||||||
|
@ -1200,13 +1197,11 @@ static BOOL currently_displaying = NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
- (NSWindow*) windowAndRect: (NSRect *)rect forObject: (id) anObject
|
- (NSWindow*) windowAndRect: (NSRect *)rect forObject: (id) anObject
|
||||||
{
|
{
|
||||||
if (anObject != _editedObject)
|
if (anObject != _editedObject)
|
||||||
{
|
{
|
||||||
NSLog(@"%@ windowAndRect: object unknown", self);
|
// NSLog(@"%@ windowAndRect: object unknown", self);
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1218,7 +1213,6 @@ static BOOL currently_displaying = NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
- (void) startConnectingObject: (id) anObject
|
- (void) startConnectingObject: (id) anObject
|
||||||
withEvent: (NSEvent *)theEvent
|
withEvent: (NSEvent *)theEvent
|
||||||
{
|
{
|
||||||
|
@ -1248,7 +1242,7 @@ static BOOL currently_displaying = NO;
|
||||||
|
|
||||||
- (BOOL) acceptsTypeFromArray: (NSArray*)types
|
- (BOOL) acceptsTypeFromArray: (NSArray*)types
|
||||||
{
|
{
|
||||||
// NSLog(@"I said why not !");
|
NSLog(@"I said why not !");
|
||||||
return [types containsObject: GormLinkPboardType];
|
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
|
- (void) mouseDown: (NSEvent*)theEvent
|
||||||
{
|
{
|
||||||
|
|
|
@ -1514,7 +1514,6 @@
|
||||||
if (activated == NO)
|
if (activated == NO)
|
||||||
{
|
{
|
||||||
NSView *contentView = [_EO contentView];
|
NSView *contentView = [_EO contentView];
|
||||||
|
|
||||||
// NSLog(@"contentView %@", contentView);
|
// NSLog(@"contentView %@", contentView);
|
||||||
contentViewEditor = [document editorForObject: contentView
|
contentViewEditor = [document editorForObject: contentView
|
||||||
inEditor: self
|
inEditor: self
|
||||||
|
@ -1751,8 +1750,11 @@
|
||||||
|
|
||||||
- (unsigned) draggingEntered: (id<NSDraggingInfo>)sender
|
- (unsigned) draggingEntered: (id<NSDraggingInfo>)sender
|
||||||
{
|
{
|
||||||
NSLog(@"********* TELL pyr *********** draggingEntered");
|
|
||||||
return NSDragOperationNone;
|
return NSDragOperationNone;
|
||||||
|
}
|
||||||
|
|
||||||
|
// - (unsigned) draggingEntered: (id<NSDraggingInfo>)sender
|
||||||
|
// {
|
||||||
// NSArray *types;
|
// NSArray *types;
|
||||||
|
|
||||||
// dragPb = [sender draggingPasteboard];
|
// dragPb = [sender draggingPasteboard];
|
||||||
|
@ -1774,12 +1776,15 @@
|
||||||
// dragType = nil;
|
// dragType = nil;
|
||||||
// }
|
// }
|
||||||
// return [self draggingUpdated: sender];
|
// return [self draggingUpdated: sender];
|
||||||
}
|
// }
|
||||||
|
|
||||||
- (unsigned) draggingUpdated: (id<NSDraggingInfo>)sender
|
- (unsigned) draggingUpdated: (id<NSDraggingInfo>)sender
|
||||||
{
|
{
|
||||||
NSLog(@"********* TELL pyr *********** draggingUpdated");
|
|
||||||
return NSDragOperationNone;
|
return NSDragOperationNone;
|
||||||
|
}
|
||||||
|
|
||||||
|
// - (unsigned) draggingUpdated: (id<NSDraggingInfo>)sender
|
||||||
|
// {
|
||||||
// if (dragType == IBViewPboardType)
|
// if (dragType == IBViewPboardType)
|
||||||
// {
|
// {
|
||||||
// return NSDragOperationCopy;
|
// return NSDragOperationCopy;
|
||||||
|
@ -1811,7 +1816,7 @@
|
||||||
// {
|
// {
|
||||||
// return NSDragOperationNone;
|
// return NSDragOperationNone;
|
||||||
// }
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
- (void) drawSelection
|
- (void) drawSelection
|
||||||
{
|
{
|
||||||
|
@ -2060,9 +2065,11 @@
|
||||||
|
|
||||||
- (BOOL) prepareForDragOperation: (id<NSDraggingInfo>)sender
|
- (BOOL) prepareForDragOperation: (id<NSDraggingInfo>)sender
|
||||||
{
|
{
|
||||||
NSLog(@"********* TELL pyr *********** prepareForDragOperation");
|
|
||||||
return NO;
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
// - (BOOL) prepareForDragOperation: (id<NSDraggingInfo>)sender
|
||||||
|
// {
|
||||||
// /*
|
// /*
|
||||||
// * Tell the source that we will accept the drop if we can.
|
// * Tell the source that we will accept the drop if we can.
|
||||||
// */
|
// */
|
||||||
|
@ -2102,7 +2109,7 @@
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// return NO;
|
// return NO;
|
||||||
}
|
// }
|
||||||
|
|
||||||
- (void) resetObject: (id)anObject
|
- (void) resetObject: (id)anObject
|
||||||
{
|
{
|
||||||
|
|
|
@ -48,6 +48,11 @@
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@interface NSButtonCell (GormObjectAdditions)
|
||||||
|
- (NSRect) gormTitleRectForFrame: (NSRect) cellFrame
|
||||||
|
inView: (NSView *)controlView;
|
||||||
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@interface GormMenuEditor : NSMenuView <IBEditors, IBSelectionOwners>
|
@interface GormMenuEditor : NSMenuView <IBEditors, IBSelectionOwners>
|
||||||
|
@ -135,6 +140,36 @@
|
||||||
{
|
{
|
||||||
NSMenuItem *item = [edited itemAtIndex: pos];
|
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];
|
[self makeSelectionVisible: NO];
|
||||||
if ([theEvent modifierFlags] & NSShiftKeyMask)
|
if ([theEvent modifierFlags] & NSShiftKeyMask)
|
||||||
{
|
{
|
||||||
|
@ -412,7 +447,6 @@
|
||||||
|
|
||||||
- (void) deactivate
|
- (void) deactivate
|
||||||
{
|
{
|
||||||
NSLog(@"deactivate");
|
|
||||||
if (original != nil)
|
if (original != nil)
|
||||||
{
|
{
|
||||||
NSEnumerator *enumerator;
|
NSEnumerator *enumerator;
|
||||||
|
@ -535,6 +569,16 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) draggingExited: (id<NSDraggingInfo>)sender
|
||||||
|
{
|
||||||
|
if (dragType == GormLinkPboardType)
|
||||||
|
{
|
||||||
|
[NSApp displayConnectionBetween: [NSApp connectSource]
|
||||||
|
and: nil];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
- (void) drawSelection
|
- (void) drawSelection
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -697,16 +741,16 @@
|
||||||
enumerator = [items objectEnumerator];
|
enumerator = [items objectEnumerator];
|
||||||
while ((item = [enumerator nextObject]) != nil)
|
while ((item = [enumerator nextObject]) != nil)
|
||||||
{
|
{
|
||||||
NSString *title = [item title];
|
// NSString *title = [item title];
|
||||||
|
|
||||||
if ([edited indexOfItemWithTitle: title] > 0)
|
// if ([edited indexOfItemWithTitle: title] > 0)
|
||||||
{
|
// {
|
||||||
[document detachObject: item]; /* Already exists */
|
// [document detachObject: item]; /* Already exists */
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
[edited insertItem: item atIndex: pos++];
|
[edited insertItem: item atIndex: pos++];
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
[edited sizeToFit];
|
[edited sizeToFit];
|
||||||
[edited display];
|
[edited display];
|
||||||
|
@ -792,6 +836,7 @@ NSLog(@"Link at index: %d (%@)", pos, NSStringFromPoint(loc));
|
||||||
NSMenuItem *item;
|
NSMenuItem *item;
|
||||||
|
|
||||||
[selection removeAllObjects];
|
[selection removeAllObjects];
|
||||||
|
NSLog(@"selectObjects %@ %@", selection, anArray);
|
||||||
[selection addObjectsFromArray: anArray];
|
[selection addObjectsFromArray: anArray];
|
||||||
|
|
||||||
count = [selection count];
|
count = [selection count];
|
||||||
|
@ -889,3 +934,105 @@ NSLog(@"Link at index: %d (%@)", pos, NSStringFromPoint(loc));
|
||||||
return [super window];
|
return [super window];
|
||||||
}
|
}
|
||||||
@end
|
@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
|
||||||
|
|
|
@ -76,6 +76,8 @@
|
||||||
[titleText setDelegate: self];
|
[titleText setDelegate: self];
|
||||||
[contents addSubview: titleText];
|
[contents addSubview: titleText];
|
||||||
RELEASE(titleText);
|
RELEASE(titleText);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -101,6 +103,7 @@
|
||||||
{
|
{
|
||||||
NSTextField *titleText;
|
NSTextField *titleText;
|
||||||
NSTextField *shortCut;
|
NSTextField *shortCut;
|
||||||
|
NSTextField *tagText;
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@ -120,6 +123,10 @@
|
||||||
|
|
||||||
[object setKeyEquivalent: s];
|
[object setKeyEquivalent: s];
|
||||||
}
|
}
|
||||||
|
if (o == tagText)
|
||||||
|
{
|
||||||
|
[object setTag: [tagText intValue]];
|
||||||
|
}
|
||||||
[[object menu] display];
|
[[object menu] display];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,6 +180,12 @@
|
||||||
[shortCut setDelegate: self];
|
[shortCut setDelegate: self];
|
||||||
[contents addSubview: shortCut];
|
[contents addSubview: shortCut];
|
||||||
RELEASE(shortCut);
|
RELEASE(shortCut);
|
||||||
|
|
||||||
|
tagText
|
||||||
|
= [[NSTextField alloc] initWithFrame: NSMakeRect(60,IVH-90,IVW-80,20)];
|
||||||
|
[tagText setDelegate: self];
|
||||||
|
[contents addSubview: tagText];
|
||||||
|
RELEASE(tagText);
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -182,6 +195,8 @@
|
||||||
[super setObject: anObject];
|
[super setObject: anObject];
|
||||||
[titleText setStringValue: [object title]];
|
[titleText setStringValue: [object title]];
|
||||||
[shortCut setStringValue: [object keyEquivalent]];
|
[shortCut setStringValue: [object keyEquivalent]];
|
||||||
|
[tagText setIntValue: [object tag]];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -24,7 +24,10 @@
|
||||||
|
|
||||||
#import <AppKit/AppKit.h>
|
#import <AppKit/AppKit.h>
|
||||||
|
|
||||||
|
@class GormDocument;
|
||||||
@interface GormNSMenu : NSMenu
|
@interface GormNSMenu : NSMenu
|
||||||
{
|
{
|
||||||
|
NSMenu *_menu;
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
@interface GormNSMenuWindow : NSWindow
|
@interface GormNSMenuWindow : NSWindow
|
||||||
{
|
{
|
||||||
|
GormDocument *_document;
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@ -38,6 +39,43 @@
|
||||||
{
|
{
|
||||||
return YES;
|
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
|
- (void) sendEvent: (NSEvent*)theEvent
|
||||||
{
|
{
|
||||||
NSEventType type;
|
NSEventType type;
|
||||||
|
@ -45,10 +83,9 @@
|
||||||
type = [theEvent type];
|
type = [theEvent type];
|
||||||
if (type == NSLeftMouseDown)
|
if (type == NSLeftMouseDown)
|
||||||
{
|
{
|
||||||
NSLog(@"here");
|
|
||||||
if (_f.is_main == YES)
|
if (_f.is_main == YES)
|
||||||
{
|
{
|
||||||
NSLog(@"already main %@", [NSApp mainWindow]);
|
// NSLog(@"already main %@", [NSApp mainWindow]);
|
||||||
}
|
}
|
||||||
[self makeMainWindow];
|
[self makeMainWindow];
|
||||||
[self makeKeyWindow];
|
[self makeKeyWindow];
|
||||||
|
@ -60,6 +97,7 @@
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation GormNSMenu
|
@implementation GormNSMenu
|
||||||
|
|
||||||
- (BOOL) performKeyEquivalent: (NSEvent*)theEvent
|
- (BOOL) performKeyEquivalent: (NSEvent*)theEvent
|
||||||
{
|
{
|
||||||
return NO;
|
return NO;
|
||||||
|
@ -69,10 +107,11 @@
|
||||||
- (NSPanel*) _createWindow
|
- (NSPanel*) _createWindow
|
||||||
{
|
{
|
||||||
NSPanel *win = [[GormNSMenuWindow alloc]
|
NSPanel *win = [[GormNSMenuWindow alloc]
|
||||||
initWithContentRect: NSZeroRect
|
initWithContentRect: NSZeroRect
|
||||||
styleMask: /*NSTitledWindowMask/*/NSBorderlessWindowMask
|
styleMask: /*NSTitledWindowMask/*/NSBorderlessWindowMask
|
||||||
backing: NSBackingStoreBuffered
|
backing: NSBackingStoreBuffered
|
||||||
defer: YES];
|
defer: YES];
|
||||||
|
[win setMenu: self];
|
||||||
[win setLevel: NSSubmenuWindowLevel];
|
[win setLevel: NSSubmenuWindowLevel];
|
||||||
|
|
||||||
// [win setWorksWhenModal: YES];
|
// [win setWorksWhenModal: YES];
|
||||||
|
|
|
@ -137,7 +137,7 @@
|
||||||
*/
|
*/
|
||||||
m = [GormNSMenu new];
|
m = [GormNSMenu new];
|
||||||
[m addItemWithTitle: @"Open..."
|
[m addItemWithTitle: @"Open..."
|
||||||
action: @selector(open:)
|
action: @selector(open:)
|
||||||
keyEquivalent: @"o"];
|
keyEquivalent: @"o"];
|
||||||
[m addItemWithTitle: @"New"
|
[m addItemWithTitle: @"New"
|
||||||
action: @selector(new:)
|
action: @selector(new:)
|
||||||
|
@ -185,13 +185,13 @@
|
||||||
*/
|
*/
|
||||||
m = [GormNSMenu new];
|
m = [GormNSMenu new];
|
||||||
[m addItemWithTitle: @"Align Left"
|
[m addItemWithTitle: @"Align Left"
|
||||||
action: @selector(alignSelLeft:)
|
action: @selector(alignLeft:)
|
||||||
keyEquivalent: @""];
|
keyEquivalent: @""];
|
||||||
[m addItemWithTitle: @"Center"
|
[m addItemWithTitle: @"Center"
|
||||||
action: @selector(alignSelCenter:)
|
action: @selector(alignCenter:)
|
||||||
keyEquivalent: @""];
|
keyEquivalent: @""];
|
||||||
[m addItemWithTitle: @"Align Right"
|
[m addItemWithTitle: @"Align Right"
|
||||||
action: @selector(alignSelRight:)
|
action: @selector(alignRight:)
|
||||||
keyEquivalent: @""];
|
keyEquivalent: @""];
|
||||||
[m addItemWithTitle: @"Show Ruler"
|
[m addItemWithTitle: @"Show Ruler"
|
||||||
action: @selector(toggleRuler:)
|
action: @selector(toggleRuler:)
|
||||||
|
@ -346,13 +346,13 @@
|
||||||
keyEquivalent: @""];
|
keyEquivalent: @""];
|
||||||
s = [GormNSMenu new];
|
s = [GormNSMenu new];
|
||||||
[s addItemWithTitle: @"Align Left"
|
[s addItemWithTitle: @"Align Left"
|
||||||
action: @selector(alignSelLeft:)
|
action: @selector(alignLeft:)
|
||||||
keyEquivalent: @""];
|
keyEquivalent: @""];
|
||||||
[s addItemWithTitle: @"Center"
|
[s addItemWithTitle: @"Center"
|
||||||
action: @selector(alignSelCenter:)
|
action: @selector(alignCenter:)
|
||||||
keyEquivalent: @""];
|
keyEquivalent: @""];
|
||||||
[s addItemWithTitle: @"Align Right"
|
[s addItemWithTitle: @"Align Right"
|
||||||
action: @selector(alignSelRight:)
|
action: @selector(alignRight:)
|
||||||
keyEquivalent: @""];
|
keyEquivalent: @""];
|
||||||
[s addItemWithTitle: @"Show Ruler"
|
[s addItemWithTitle: @"Show Ruler"
|
||||||
action: @selector(toggleRuler:)
|
action: @selector(toggleRuler:)
|
||||||
|
|
|
@ -25,7 +25,11 @@ include $(GNUSTEP_MAKEFILES)/common.make
|
||||||
|
|
||||||
PALETTE_NAME = 2Controls
|
PALETTE_NAME = 2Controls
|
||||||
2Controls_PALETTE_ICON = ControlsPalette
|
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_PRINCIPAL_CLASS = ControlsPalette
|
||||||
|
|
||||||
2Controls_RESOURCE_FILES = ControlsPalette.tiff \
|
2Controls_RESOURCE_FILES = ControlsPalette.tiff \
|
||||||
|
|
137
Palettes/2Controls/GormPopUpButtonEditor.m
Normal file
137
Palettes/2Controls/GormPopUpButtonEditor.m
Normal 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
|
|
@ -817,7 +817,11 @@
|
||||||
{
|
{
|
||||||
if (control == typeMatrix)
|
if (control == typeMatrix)
|
||||||
{
|
{
|
||||||
|
id selectedItem;
|
||||||
[object setPullsDown: [[control selectedCell] tag]];
|
[object setPullsDown: [[control selectedCell] tag]];
|
||||||
|
selectedItem = [object selectedItem];
|
||||||
|
[object selectItem: nil];
|
||||||
|
[object selectItem: selectedItem];
|
||||||
}
|
}
|
||||||
else if (control == disabledSwitch)
|
else if (control == disabledSwitch)
|
||||||
{
|
{
|
||||||
|
|
|
@ -26,6 +26,9 @@
|
||||||
#include "../../Gorm.h"
|
#include "../../Gorm.h"
|
||||||
#include "../../GormCustomView.h"
|
#include "../../GormCustomView.h"
|
||||||
|
|
||||||
|
// @class GormPopUpNSMenu;
|
||||||
|
@class GormNSPopUpButton;
|
||||||
|
|
||||||
@interface ControlsPalette: IBPalette
|
@interface ControlsPalette: IBPalette
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -147,7 +150,7 @@
|
||||||
/*******************/
|
/*******************/
|
||||||
|
|
||||||
// Popup button
|
// 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 1"];
|
||||||
[v addItemWithTitle: @"Item 2"];
|
[v addItemWithTitle: @"Item 2"];
|
||||||
[v addItemWithTitle: @"Item 3"];
|
[v addItemWithTitle: @"Item 3"];
|
||||||
|
|
|
@ -80,8 +80,6 @@ static NSText *_textObject;
|
||||||
*/
|
*/
|
||||||
- (BOOL) activate
|
- (BOOL) activate
|
||||||
{
|
{
|
||||||
NSLog(@"activate");
|
|
||||||
|
|
||||||
if ([super activate])
|
if ([super activate])
|
||||||
{
|
{
|
||||||
if ([_editedObject isKindOfClass: [NSScrollView class]])
|
if ([_editedObject isKindOfClass: [NSScrollView class]])
|
||||||
|
@ -402,6 +400,120 @@ static NSText *_textObject;
|
||||||
// return [NSArray arrayWithObject: selected];
|
// 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
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -197,6 +197,7 @@ int defaultDateFormatIndex = 3;
|
||||||
id v;
|
id v;
|
||||||
NSNumberFormatter *nf;
|
NSNumberFormatter *nf;
|
||||||
NSDateFormatter *df;
|
NSDateFormatter *df;
|
||||||
|
NSRect rect;
|
||||||
|
|
||||||
|
|
||||||
window = [[NSWindow alloc] initWithContentRect: NSMakeRect(0, 0, 272, 192)
|
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 = [[NSScrollView alloc] initWithFrame: NSMakeRect(20, 22, 113,148)];
|
||||||
[v setHasVerticalScroller: YES];
|
[v setHasVerticalScroller: YES];
|
||||||
[v setHasHorizontalScroller: NO];
|
[v setHasHorizontalScroller: NO];
|
||||||
// [v setAutoresizingMask: NSViewHeightSizable|NSViewWidthSizable];
|
[v setAutoresizingMask: NSViewHeightSizable | NSViewWidthSizable];
|
||||||
contentSize = [v contentSize];
|
[[v contentView] setAutoresizingMask: NSViewHeightSizable
|
||||||
|
| NSViewWidthSizable];
|
||||||
|
[[v contentView] setAutoresizesSubviews:YES];
|
||||||
|
|
||||||
tv = [[NSTextView alloc] initWithFrame:
|
rect = [[v contentView] frame];
|
||||||
NSMakeRect(0,0,contentSize.width, contentSize.height)];
|
|
||||||
|
tv = [[NSTextView alloc] initWithFrame: rect];
|
||||||
[tv setMinSize: NSMakeSize(0.0, 0.0)];
|
[tv setMinSize: NSMakeSize(0.0, 0.0)];
|
||||||
[tv setMaxSize: NSMakeSize(1.0E7,1.0E7)];
|
[tv setMaxSize: NSMakeSize(1.0E7,1.0E7)];
|
||||||
[tv setVerticallyResizable:YES];
|
[tv setHorizontallyResizable: NO];
|
||||||
[tv setHorizontallyResizable:NO];
|
[tv setVerticallyResizable: YES];
|
||||||
[tv setAutoresizingMask: NSViewWidthSizable];
|
[tv setAutoresizingMask: NSViewWidthSizable];
|
||||||
[tv setSelectable: YES];
|
[tv setSelectable: YES];
|
||||||
[tv setEditable: YES];
|
[tv setEditable: YES];
|
||||||
[tv setRichText: YES];
|
[tv setRichText: YES];
|
||||||
[tv setImportsGraphics: YES];
|
[tv setImportsGraphics: YES];
|
||||||
|
|
||||||
[[tv textContainer] setContainerSize:contentSize];
|
[[tv textContainer] setContainerSize:NSMakeSize(rect.size.width,
|
||||||
|
1e7)];
|
||||||
[[tv textContainer] setWidthTracksTextView:YES];
|
[[tv textContainer] setWidthTracksTextView:YES];
|
||||||
|
|
||||||
[v setDocumentView:tv];
|
[v setDocumentView:tv];
|
||||||
|
|
Loading…
Reference in a new issue