mirror of
https://github.com/gnustep/apps-gorm.git
synced 2025-02-24 03:51:22 +00:00
* Palettes/0Menus/GormMenuEditor.m: Revert some changes from
previous modification. Corrects issue with submenus showing up when they shouldn't. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@27847 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
d495893e23
commit
b6da98f29d
2 changed files with 203 additions and 217 deletions
|
@ -1,3 +1,9 @@
|
|||
2009-02-11 09:22-EST Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* Palettes/0Menus/GormMenuEditor.m: Revert some changes from
|
||||
previous modification. Corrects issue with submenus showing up
|
||||
when they shouldn't.
|
||||
|
||||
2009-02-11 01:31-EST Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* GormCore/GormDocument.m: Remove call to deprecated method.
|
||||
|
|
|
@ -125,230 +125,216 @@
|
|||
{
|
||||
NSPoint loc = [theEvent locationInWindow];
|
||||
NSView *hit = [super hitTest: loc];
|
||||
NSView *view = nil;
|
||||
|
||||
[edited display];
|
||||
|
||||
[[self window] becomeMainWindow];
|
||||
[[self window] makeFirstResponder: self];
|
||||
|
||||
if([hit isKindOfClass: [NSMenuView class]] &&
|
||||
![edited _ownedByPopUp])
|
||||
if (hit == rep)
|
||||
{
|
||||
view = [[hit subviews] objectAtIndex: 0];
|
||||
}
|
||||
int pos = [rep indexOfItemAtPoint: loc];
|
||||
|
||||
if([view isKindOfClass: [NSMenuView class]] ||
|
||||
[hit isKindOfClass: [NSMenuView class]])
|
||||
{
|
||||
if (view == rep ||
|
||||
hit == rep)
|
||||
if (pos >= 0)
|
||||
{
|
||||
int pos = [rep indexOfItemAtPoint: loc];
|
||||
|
||||
if (pos >= 0)
|
||||
NSMenuItem *item = [edited itemAtIndex: pos];
|
||||
|
||||
if ([theEvent clickCount] == 2)
|
||||
{
|
||||
NSMenuItem *item = [edited itemAtIndex: pos];
|
||||
|
||||
if ([theEvent clickCount] == 2)
|
||||
{
|
||||
id cell;
|
||||
NSTextField *tf;
|
||||
NSRect frame;
|
||||
[self makeSelectionVisible: NO];
|
||||
[self selectObjects: [NSArray array]];
|
||||
cell = [rep menuItemCellForItemAtIndex: pos];
|
||||
tf = [[NSTextField alloc] initWithFrame: [self bounds]];
|
||||
frame = (NSRect)[cell titleRectForBounds:
|
||||
[rep rectOfItemAtIndex: pos]];
|
||||
NSDebugLog(@"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];
|
||||
[self addSubview: tf];
|
||||
[tf setStringValue: [[cell menuItem] title]];
|
||||
[self editTextField: tf
|
||||
withEvent: theEvent];
|
||||
[[cell menuItem] setTitle: [tf stringValue]];
|
||||
[tf removeFromSuperview];
|
||||
RELEASE(tf);
|
||||
return;
|
||||
}
|
||||
|
||||
id cell;
|
||||
NSTextField *tf;
|
||||
NSRect frame;
|
||||
[self makeSelectionVisible: NO];
|
||||
if ([theEvent modifierFlags] & NSShiftKeyMask)
|
||||
[self selectObjects: [NSArray array]];
|
||||
cell = [rep menuItemCellForItemAtIndex: pos];
|
||||
tf = [[NSTextField alloc] initWithFrame: [self bounds]];
|
||||
frame = (NSRect)[cell titleRectForBounds:
|
||||
[rep rectOfItemAtIndex: pos]];
|
||||
NSDebugLog(@"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];
|
||||
[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)
|
||||
{
|
||||
NSMutableArray *array;
|
||||
|
||||
array = [NSMutableArray arrayWithArray: selection];
|
||||
if ([array containsObject: item] == YES)
|
||||
{
|
||||
NSMutableArray *array;
|
||||
|
||||
array = [NSMutableArray arrayWithArray: selection];
|
||||
if ([array containsObject: item] == YES)
|
||||
{
|
||||
[array removeObject: item];
|
||||
}
|
||||
else
|
||||
{
|
||||
[array addObject: item];
|
||||
}
|
||||
[self selectObjects: array];
|
||||
[self makeSelectionVisible: YES];
|
||||
return;
|
||||
}
|
||||
|
||||
[self selectObjects: [NSArray arrayWithObject: item]];
|
||||
if ([theEvent modifierFlags] & NSControlKeyMask)
|
||||
{
|
||||
NSPoint dragPoint = [theEvent locationInWindow];
|
||||
NSPasteboard *pb;
|
||||
NSString *name = [document nameForObject: item];
|
||||
|
||||
pb = [NSPasteboard pasteboardWithName: NSDragPboard];
|
||||
[pb declareTypes:
|
||||
[NSArray arrayWithObject: GormLinkPboardType]
|
||||
owner: self];
|
||||
[pb setString: name forType: GormLinkPboardType];
|
||||
[NSApp displayConnectionBetween: item and: nil];
|
||||
[NSApp startConnecting];
|
||||
|
||||
isLinkSource = YES;
|
||||
[self dragImage: [NSApp linkImage]
|
||||
at: dragPoint
|
||||
offset: NSZeroSize
|
||||
event: theEvent
|
||||
pasteboard: pb
|
||||
source: self
|
||||
slideBack: YES];
|
||||
isLinkSource = NO;
|
||||
[array removeObject: item];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSDate *future = [NSDate distantFuture];
|
||||
unsigned eventMask;
|
||||
NSEvent *e;
|
||||
NSEventType eType;
|
||||
BOOL acceptsMouseMoved;
|
||||
NSRect frame = [rep innerRect];
|
||||
float maxMouse = NSMaxY(frame);
|
||||
float minMouse = NSMinY(frame);
|
||||
NSPoint lastPoint = loc;
|
||||
NSPoint point = loc;
|
||||
NSRect lastRect = [rep rectOfItemAtIndex: pos];
|
||||
id cell = [rep menuItemCellForItemAtIndex: pos];
|
||||
int newPos;
|
||||
|
||||
eventMask = NSLeftMouseUpMask | NSLeftMouseDraggedMask
|
||||
| NSMouseMovedMask | NSPeriodicMask;
|
||||
[[self window] setAcceptsMouseMovedEvents: YES];
|
||||
|
||||
/*
|
||||
* Save window state info.
|
||||
*/
|
||||
acceptsMouseMoved = [[self window] acceptsMouseMovedEvents];
|
||||
[rep lockFocus];
|
||||
|
||||
/*
|
||||
* Track mouse movements until left mouse up.
|
||||
* While we keep track of all mouse movements,
|
||||
* we only act on a movement when a periodic
|
||||
* event arives (every 20th of a second)
|
||||
* in order to avoid excessive amounts of drawing.
|
||||
*/
|
||||
[NSEvent startPeriodicEventsAfterDelay: 0.1 withPeriod: 0.05];
|
||||
e = [NSApp nextEventMatchingMask: eventMask
|
||||
untilDate: future
|
||||
inMode: NSEventTrackingRunLoopMode
|
||||
dequeue: YES];
|
||||
eType = [e type];
|
||||
while (eType != NSLeftMouseUp)
|
||||
{
|
||||
if (eType != NSPeriodic)
|
||||
{
|
||||
point = [e locationInWindow];
|
||||
}
|
||||
else if (NSEqualPoints(point, lastPoint) == NO)
|
||||
{
|
||||
/*
|
||||
* Limit mouse movement.
|
||||
*/
|
||||
point.x = NSMinX(frame);
|
||||
if (point.y < minMouse)
|
||||
point.y = minMouse;
|
||||
if (point.y > maxMouse)
|
||||
point.y = maxMouse;
|
||||
|
||||
if (NSEqualPoints(point, lastPoint) == NO)
|
||||
{
|
||||
[[self window] disableFlushWindow];
|
||||
|
||||
/*
|
||||
* Redraw cells under area being changed.
|
||||
*/
|
||||
[rep drawRect: lastRect];
|
||||
|
||||
/*
|
||||
* Update location.
|
||||
*/
|
||||
lastRect.origin.y += point.y - lastPoint.y;
|
||||
lastPoint = point;
|
||||
|
||||
/*
|
||||
* Draw highlighted item being moved.
|
||||
*/
|
||||
[cell highlight: YES withFrame: lastRect inView: rep];
|
||||
[cell setHighlighted: NO];
|
||||
|
||||
/*
|
||||
* Flush any drawing performed for this event.
|
||||
*/
|
||||
[[self window] enableFlushWindow];
|
||||
[[self window] flushWindow];
|
||||
}
|
||||
}
|
||||
e = [NSApp nextEventMatchingMask: eventMask
|
||||
untilDate: future
|
||||
inMode: NSEventTrackingRunLoopMode
|
||||
dequeue: YES];
|
||||
eType = [e type];
|
||||
}
|
||||
[NSEvent stopPeriodicEvents];
|
||||
|
||||
[rep drawRect: lastRect];
|
||||
[rep unlockFocus];
|
||||
newPos = [rep indexOfItemAtPoint: point];
|
||||
if (newPos < pos)
|
||||
{
|
||||
NSMenuItem *item = [edited itemAtIndex: pos];
|
||||
|
||||
RETAIN(item);
|
||||
if (newPos < 0)
|
||||
newPos = 0;
|
||||
[edited removeItemAtIndex: pos];
|
||||
[edited insertItem: item atIndex: newPos];
|
||||
RELEASE(item);
|
||||
}
|
||||
else if (newPos > pos)
|
||||
{
|
||||
NSMenuItem *item = [edited itemAtIndex: pos];
|
||||
|
||||
RETAIN(item);
|
||||
[edited removeItemAtIndex: pos];
|
||||
[edited insertItem: item atIndex: newPos];
|
||||
RELEASE(item);
|
||||
}
|
||||
[edited sizeToFit];
|
||||
[edited display];
|
||||
/*
|
||||
* Restore state to what it was on entry.
|
||||
*/
|
||||
[[self window] setAcceptsMouseMovedEvents: acceptsMouseMoved];
|
||||
[array addObject: item];
|
||||
}
|
||||
[self selectObjects: array];
|
||||
[self makeSelectionVisible: YES];
|
||||
return;
|
||||
}
|
||||
|
||||
[self selectObjects: [NSArray arrayWithObject: item]];
|
||||
if ([theEvent modifierFlags] & NSControlKeyMask)
|
||||
{
|
||||
NSPoint dragPoint = [theEvent locationInWindow];
|
||||
NSPasteboard *pb;
|
||||
NSString *name = [document nameForObject: item];
|
||||
|
||||
pb = [NSPasteboard pasteboardWithName: NSDragPboard];
|
||||
[pb declareTypes:
|
||||
[NSArray arrayWithObject: GormLinkPboardType]
|
||||
owner: self];
|
||||
[pb setString: name forType: GormLinkPboardType];
|
||||
[NSApp displayConnectionBetween: item and: nil];
|
||||
[NSApp startConnecting];
|
||||
|
||||
isLinkSource = YES;
|
||||
[self dragImage: [NSApp linkImage]
|
||||
at: dragPoint
|
||||
offset: NSZeroSize
|
||||
event: theEvent
|
||||
pasteboard: pb
|
||||
source: self
|
||||
slideBack: YES];
|
||||
isLinkSource = NO;
|
||||
}
|
||||
else
|
||||
{
|
||||
NSDate *future = [NSDate distantFuture];
|
||||
unsigned eventMask;
|
||||
NSEvent *e;
|
||||
NSEventType eType;
|
||||
BOOL acceptsMouseMoved;
|
||||
NSRect frame = [rep innerRect];
|
||||
float maxMouse = NSMaxY(frame);
|
||||
float minMouse = NSMinY(frame);
|
||||
NSPoint lastPoint = loc;
|
||||
NSPoint point = loc;
|
||||
NSRect lastRect = [rep rectOfItemAtIndex: pos];
|
||||
id cell = [rep menuItemCellForItemAtIndex: pos];
|
||||
int newPos;
|
||||
|
||||
eventMask = NSLeftMouseUpMask | NSLeftMouseDraggedMask
|
||||
| NSMouseMovedMask | NSPeriodicMask;
|
||||
[[self window] setAcceptsMouseMovedEvents: YES];
|
||||
|
||||
/*
|
||||
* Save window state info.
|
||||
*/
|
||||
acceptsMouseMoved = [[self window] acceptsMouseMovedEvents];
|
||||
[rep lockFocus];
|
||||
|
||||
/*
|
||||
* Track mouse movements until left mouse up.
|
||||
* While we keep track of all mouse movements,
|
||||
* we only act on a movement when a periodic
|
||||
* event arives (every 20th of a second)
|
||||
* in order to avoid excessive amounts of drawing.
|
||||
*/
|
||||
[NSEvent startPeriodicEventsAfterDelay: 0.1 withPeriod: 0.05];
|
||||
e = [NSApp nextEventMatchingMask: eventMask
|
||||
untilDate: future
|
||||
inMode: NSEventTrackingRunLoopMode
|
||||
dequeue: YES];
|
||||
eType = [e type];
|
||||
while (eType != NSLeftMouseUp)
|
||||
{
|
||||
if (eType != NSPeriodic)
|
||||
{
|
||||
point = [e locationInWindow];
|
||||
}
|
||||
else if (NSEqualPoints(point, lastPoint) == NO)
|
||||
{
|
||||
/*
|
||||
* Limit mouse movement.
|
||||
*/
|
||||
point.x = NSMinX(frame);
|
||||
if (point.y < minMouse)
|
||||
point.y = minMouse;
|
||||
if (point.y > maxMouse)
|
||||
point.y = maxMouse;
|
||||
|
||||
if (NSEqualPoints(point, lastPoint) == NO)
|
||||
{
|
||||
[[self window] disableFlushWindow];
|
||||
|
||||
/*
|
||||
* Redraw cells under area being changed.
|
||||
*/
|
||||
[rep drawRect: lastRect];
|
||||
|
||||
/*
|
||||
* Update location.
|
||||
*/
|
||||
lastRect.origin.y += point.y - lastPoint.y;
|
||||
lastPoint = point;
|
||||
|
||||
/*
|
||||
* Draw highlighted item being moved.
|
||||
*/
|
||||
[cell highlight: YES withFrame: lastRect inView: rep];
|
||||
[cell setHighlighted: NO];
|
||||
|
||||
/*
|
||||
* Flush any drawing performed for this event.
|
||||
*/
|
||||
[[self window] enableFlushWindow];
|
||||
[[self window] flushWindow];
|
||||
}
|
||||
}
|
||||
e = [NSApp nextEventMatchingMask: eventMask
|
||||
untilDate: future
|
||||
inMode: NSEventTrackingRunLoopMode
|
||||
dequeue: YES];
|
||||
eType = [e type];
|
||||
}
|
||||
[NSEvent stopPeriodicEvents];
|
||||
|
||||
[rep drawRect: lastRect];
|
||||
[rep unlockFocus];
|
||||
newPos = [rep indexOfItemAtPoint: point];
|
||||
if (newPos < pos)
|
||||
{
|
||||
NSMenuItem *item = [edited itemAtIndex: pos];
|
||||
|
||||
RETAIN(item);
|
||||
if (newPos < 0)
|
||||
newPos = 0;
|
||||
[edited removeItemAtIndex: pos];
|
||||
[edited insertItem: item atIndex: newPos];
|
||||
RELEASE(item);
|
||||
}
|
||||
else if (newPos > pos)
|
||||
{
|
||||
NSMenuItem *item = [edited itemAtIndex: pos];
|
||||
|
||||
RETAIN(item);
|
||||
[edited removeItemAtIndex: pos];
|
||||
[edited insertItem: item atIndex: newPos];
|
||||
RELEASE(item);
|
||||
}
|
||||
[edited sizeToFit];
|
||||
[edited display];
|
||||
/*
|
||||
* Restore state to what it was on entry.
|
||||
*/
|
||||
[[self window] setAcceptsMouseMovedEvents: acceptsMouseMoved];
|
||||
}
|
||||
[self makeSelectionVisible: YES];
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -359,10 +345,7 @@
|
|||
*/
|
||||
[[document parentEditorForEditor: self] selectObjects:
|
||||
[NSArray arrayWithObject: edited]];
|
||||
if(hit != self)
|
||||
{
|
||||
[hit mouseDown: theEvent];
|
||||
}
|
||||
[hit mouseDown: theEvent];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -675,7 +658,6 @@ void _attachAll(NSMenu *menu, id document)
|
|||
* Make sure that all our menu items are attached in the document.
|
||||
*/
|
||||
_attachAll(edited, document);
|
||||
[edited display];
|
||||
}
|
||||
|
||||
return self;
|
||||
|
@ -833,7 +815,8 @@ void _attachAll(NSMenu *menu, id document)
|
|||
NSDebugLog(@"not owned by popup");
|
||||
[edited insertItem: item atIndex: pos++];
|
||||
}
|
||||
|
||||
[edited sizeToFit];
|
||||
[edited display];
|
||||
[self selectObjects: items];
|
||||
[self makeSelectionVisible: YES];
|
||||
}
|
||||
|
@ -857,9 +840,6 @@ void _attachAll(NSMenu *menu, id document)
|
|||
dragType = nil;
|
||||
return NO;
|
||||
}
|
||||
|
||||
[edited sizeToFit];
|
||||
[edited display];
|
||||
dragType = nil;
|
||||
return YES;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue