mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 07:00:46 +00:00
Merge with trunk revision 40072
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/branches/gnustep_testplant_branch@40132 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
ab97ddee5f
commit
8bdc94322b
6 changed files with 108 additions and 90 deletions
|
@ -1270,8 +1270,27 @@ static NSImage *_pbc_image[5];
|
|||
{
|
||||
/* First decode menu, menu items must be available to set the selection */
|
||||
menu = [aDecoder decodeObjectForKey: @"NSMenu"];
|
||||
[self setMenu: nil];
|
||||
[self setMenu: menu];
|
||||
if (menu)
|
||||
{
|
||||
NSEnumerator *menuItemEnumerator;
|
||||
NSMenuItem *menuItem;
|
||||
|
||||
[self setMenu: nil];
|
||||
[self setMenu: menu];
|
||||
|
||||
// FIXME: This special handling is needed bacause the NSClassSwapper
|
||||
// might have replaced the cell, but the items still refere to it.
|
||||
menuItemEnumerator = [[menu itemArray] objectEnumerator];
|
||||
|
||||
while ((menuItem = [menuItemEnumerator nextObject]) != nil)
|
||||
{
|
||||
if (sel_isEqual([menuItem action], @selector(_popUpItemAction:))
|
||||
&& ([menuItem target] != self))
|
||||
{
|
||||
[menuItem setTarget: self];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ([aDecoder containsValueForKey: @"NSAltersState"])
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
*
|
||||
* Author: Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
* Author: Gregory John Casamento <greg.casamento@gmail.com>
|
||||
* Date: 2007
|
||||
*
|
||||
* This file is part of GNUstep.
|
||||
|
@ -544,16 +544,12 @@
|
|||
withView: (NSView *)view
|
||||
{
|
||||
id segment = [_items objectAtIndex: seg];
|
||||
NSString *label = [segment label];
|
||||
NSSize textSize = [label sizeWithAttributes: [NSDictionary dictionary]];
|
||||
NSRect textFrame = frame;
|
||||
CGFloat x_offset = (frame.size.width - textSize.width) / 2;
|
||||
NSString *label = [self labelForSegment: seg];
|
||||
NSImage *segmentImage = [self imageForSegment: seg];
|
||||
GSThemeControlState state = GSThemeNormalState;
|
||||
BOOL roundedLeft = NO;
|
||||
BOOL roundedRight = NO;
|
||||
|
||||
textFrame.origin.x += x_offset;
|
||||
textFrame.size.width -= x_offset;
|
||||
[segment setFrame: frame];
|
||||
|
||||
if([segment isSelected])
|
||||
|
@ -562,10 +558,14 @@
|
|||
}
|
||||
|
||||
if (seg == 0)
|
||||
{
|
||||
roundedLeft = YES;
|
||||
}
|
||||
|
||||
if (seg == ([_items count] - 1))
|
||||
{
|
||||
roundedRight = YES;
|
||||
}
|
||||
|
||||
[[GSTheme theme] drawSegmentedControlSegment: self
|
||||
withFrame: frame
|
||||
|
@ -574,7 +574,37 @@
|
|||
state: state
|
||||
roundedLeft: roundedLeft
|
||||
roundedRight: roundedRight];
|
||||
[self _drawText: [segment label] inFrame: textFrame];
|
||||
if (label)
|
||||
{
|
||||
NSSize textSize = [label sizeWithAttributes: [self _nonAutoreleasedTypingAttributes]];
|
||||
NSRect textFrame = frame;
|
||||
CGFloat x_offset = (frame.size.width - textSize.width) / 2;
|
||||
|
||||
textFrame.origin.x += x_offset;
|
||||
textFrame.size.width -= x_offset;
|
||||
[self _drawText: label inFrame: textFrame];
|
||||
}
|
||||
|
||||
if (segmentImage)
|
||||
{
|
||||
NSSize size = [segmentImage size];
|
||||
NSPoint position;
|
||||
NSRect destinationRect;
|
||||
|
||||
position.x = MAX(NSMidX(frame) - (size.width/2.), 0.);
|
||||
position.y = MAX(NSMidY(frame) - (size.height/2.), 0.);
|
||||
destinationRect = NSMakeRect(position.x, position.y, size.width, size.height);
|
||||
|
||||
if (nil != view)
|
||||
{
|
||||
destinationRect = [view centerScanRect: destinationRect];
|
||||
}
|
||||
|
||||
[segmentImage drawInRect: destinationRect
|
||||
fromRect: NSZeroRect
|
||||
operation: NSCompositeSourceOver
|
||||
fraction: 1.0];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) drawInteriorWithFrame: (NSRect)cellFrame
|
||||
|
|
|
@ -848,116 +848,77 @@ float _floatValueForMousePoint (NSPoint point, NSRect knobRect,
|
|||
return 0.0;
|
||||
}
|
||||
|
||||
- (BOOL) trackMouse: (NSEvent*)theEvent
|
||||
inRect: (NSRect)cellFrame
|
||||
ofView: (NSView*)controlView
|
||||
untilMouseUp: (BOOL)flag
|
||||
- (BOOL) startTrackingAt: (NSPoint)startPoint inView: (NSView*)controlView
|
||||
{
|
||||
float delay;
|
||||
float interval;
|
||||
id target = [self target];
|
||||
SEL action = [self action];
|
||||
NSUInteger eventMask = NSLeftMouseDownMask | NSLeftMouseUpMask
|
||||
| NSLeftMouseDraggedMask | NSMouseMovedMask;
|
||||
NSEventType eventType = [theEvent type];
|
||||
BOOL isContinuous = [self isContinuous];
|
||||
float oldFloatValue = [self floatValue];
|
||||
NSRect slotRect = [self trackRect];
|
||||
BOOL isVertical = [self isVertical];
|
||||
double minValue = [self minValue];
|
||||
double maxValue = [self maxValue];
|
||||
// If the point is in the view then yes start tracking
|
||||
if ([controlView mouse: startPoint inRect: [controlView bounds]])
|
||||
{
|
||||
BOOL isFlipped = [controlView isFlipped];
|
||||
NSPoint location = [theEvent locationInWindow];
|
||||
NSPoint point = [controlView convertPoint: location fromView: nil];
|
||||
NSRect knobRect = [self knobRectFlipped: isFlipped];
|
||||
|
||||
_mouse_down_flags = [theEvent modifierFlags];
|
||||
if (![self isEnabled])
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (![controlView mouse: point inRect: knobRect])
|
||||
if (![controlView mouse: startPoint inRect: knobRect])
|
||||
{
|
||||
// Mouse is not on the knob, move the knob to the mouse position
|
||||
float floatValue;
|
||||
NSRect slotRect = [self trackRect];
|
||||
BOOL isVertical = [self isVertical];
|
||||
double minValue = [self minValue];
|
||||
double maxValue = [self maxValue];
|
||||
|
||||
floatValue = _floatValueForMousePoint(point, knobRect,
|
||||
floatValue = _floatValueForMousePoint(startPoint, knobRect,
|
||||
slotRect, isVertical,
|
||||
minValue, maxValue,
|
||||
self, isFlipped,
|
||||
(_type == NSCircularSlider));
|
||||
if (_allowsTickMarkValuesOnly)
|
||||
{
|
||||
floatValue = [self closestTickMarkValueToValue: floatValue];
|
||||
}
|
||||
[self setFloatValue: floatValue];
|
||||
if (isContinuous)
|
||||
if ([self isContinuous])
|
||||
{
|
||||
[(NSControl*)controlView sendAction: action to: target];
|
||||
[(NSControl*)controlView sendAction: [self action] to: [self target]];
|
||||
}
|
||||
}
|
||||
|
||||
if (isContinuous)
|
||||
{
|
||||
[self getPeriodicDelay: &delay interval: &interval];
|
||||
[NSEvent startPeriodicEventsAfterDelay: delay withPeriod: interval];
|
||||
eventMask |= NSPeriodicMask;
|
||||
return YES;
|
||||
}
|
||||
|
||||
while (eventType != NSLeftMouseUp)
|
||||
{
|
||||
theEvent = [NSApp nextEventMatchingMask: eventMask
|
||||
untilDate: [NSDate distantFuture]
|
||||
inMode: NSEventTrackingRunLoopMode
|
||||
dequeue: YES];
|
||||
eventType = [theEvent type];
|
||||
|
||||
if (eventType == NSPeriodic)
|
||||
{
|
||||
NSWindow *w = [controlView window];
|
||||
|
||||
location = [w mouseLocationOutsideOfEventStream];
|
||||
}
|
||||
else
|
||||
{
|
||||
location = [theEvent locationInWindow];
|
||||
return NO;
|
||||
}
|
||||
point = [controlView convertPoint: location fromView: nil];
|
||||
}
|
||||
|
||||
if (point.x != knobRect.origin.x || point.y != knobRect.origin.y)
|
||||
- (BOOL) continueTracking: (NSPoint)lastPoint
|
||||
at: (NSPoint)currentPoint
|
||||
inView: (NSView*)controlView
|
||||
{
|
||||
if (currentPoint.x != lastPoint.x || currentPoint.y != lastPoint.y)
|
||||
{
|
||||
float floatValue;
|
||||
BOOL isFlipped = [controlView isFlipped];
|
||||
NSRect knobRect = [self knobRectFlipped: isFlipped];
|
||||
float oldFloatValue = [self floatValue];
|
||||
NSRect slotRect = [self trackRect];
|
||||
BOOL isVertical = [self isVertical];
|
||||
double minValue = [self minValue];
|
||||
double maxValue = [self maxValue];
|
||||
|
||||
floatValue = _floatValueForMousePoint(point, knobRect,
|
||||
floatValue = _floatValueForMousePoint(currentPoint, knobRect,
|
||||
slotRect, isVertical,
|
||||
minValue, maxValue,
|
||||
self, isFlipped,
|
||||
(_type == NSCircularSlider));
|
||||
if (floatValue != oldFloatValue)
|
||||
{
|
||||
if (_allowsTickMarkValuesOnly)
|
||||
{
|
||||
floatValue = [self closestTickMarkValueToValue:floatValue];
|
||||
}
|
||||
|
||||
[self setFloatValue: floatValue];
|
||||
if (isContinuous)
|
||||
if (floatValue != oldFloatValue)
|
||||
{
|
||||
[(NSControl*)controlView sendAction: action to: target];
|
||||
[self setFloatValue: floatValue];
|
||||
// The action gets triggered in trackMouse:...untilMouseUp:
|
||||
}
|
||||
oldFloatValue = floatValue;
|
||||
}
|
||||
knobRect.origin = point;
|
||||
}
|
||||
}
|
||||
|
||||
// If the cell is not continuous send the action at the end of the drag
|
||||
if (!isContinuous)
|
||||
{
|
||||
[(NSControl*)controlView sendAction: action to: target];
|
||||
}
|
||||
else
|
||||
{
|
||||
[NSEvent stopPeriodicEvents];
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
|
|
@ -322,6 +322,7 @@ static NSNotificationCenter *nc = nil;
|
|||
* Utility function handling the splitview resize after
|
||||
* the divider has been moved
|
||||
*/
|
||||
// Testplant-MAL-2016-10-05: DPS modified code for notification userinfo...
|
||||
- (void) _resize: (id) v withOldSplitView: (id) prev
|
||||
withFrame: (NSRect) r fromPoint: (NSPoint) p
|
||||
withBigRect: (NSRect) bigRect divHorizontal: (CGFloat) divHorizontal
|
||||
|
@ -1053,6 +1054,7 @@ static inline NSPoint centerSizeInRect(NSSize innerSize, NSRect outerRect)
|
|||
|
||||
- (void) setAutosaveName: (NSString *)autosaveName
|
||||
{
|
||||
// Testplant-MAL-2016-10-05: DPS modified code for nil autosave names...
|
||||
if ([autosaveName length] == 0)
|
||||
autosaveName = nil;
|
||||
ASSIGN(_autosaveName, autosaveName);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/** <title>NSTabViewItem</title>
|
||||
|
||||
Copyright (C) 2000 Free Software Foundation, Inc.
|
||||
Copyright (C) 2000-2016 Free Software Foundation, Inc.
|
||||
|
||||
Author: Michael Hanni <mhanni@sprintmail.com>
|
||||
Date: 1999
|
||||
|
@ -98,12 +98,17 @@
|
|||
|
||||
- (NSSize) sizeOfLabel: (BOOL)shouldTruncateLabel
|
||||
{
|
||||
NSDictionary * attr = [[NSDictionary alloc] initWithObjectsAndKeys:
|
||||
[_tabview font], NSFontAttributeName,
|
||||
nil];
|
||||
NSDictionary * attr;
|
||||
NSString *string;
|
||||
NSSize rSize;
|
||||
|
||||
if (nil == _label)
|
||||
return NSZeroSize;
|
||||
|
||||
attr = [[NSDictionary alloc] initWithObjectsAndKeys:
|
||||
[_tabview font], NSFontAttributeName,
|
||||
nil];
|
||||
|
||||
if (shouldTruncateLabel)
|
||||
{
|
||||
string = [self _truncatedLabel];
|
||||
|
@ -178,6 +183,9 @@
|
|||
NSDictionary *attr;
|
||||
NSString *string;
|
||||
|
||||
if (nil == _label)
|
||||
return;
|
||||
|
||||
_rect = tabRect;
|
||||
|
||||
if (shouldTruncateLabel)
|
||||
|
|
|
@ -148,7 +148,6 @@ static NSNotificationCenter *nc = nil;
|
|||
/*
|
||||
* Extend edited range to encompass the latest edit.
|
||||
*/
|
||||
// Testplant-MAL-2015-07-08: keeping testplant branch code...
|
||||
if (_editedMask == 0)
|
||||
{
|
||||
_editedRange = old; // First edit.
|
||||
|
@ -158,7 +157,6 @@ static NSNotificationCenter *nc = nil;
|
|||
_editedRange = NSUnionRange (_editedRange, old);
|
||||
}
|
||||
|
||||
// Testplant-MAL-2015-07-08: keeping testplant branch code...
|
||||
/*
|
||||
* Add in any new flags for this edit.
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue