mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-01 18:31:55 +00:00
Multiple commits from Michael, see ChangeLog.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@16458 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
02b5808b0b
commit
8df511620b
7 changed files with 260 additions and 176 deletions
25
ChangeLog
25
ChangeLog
|
@ -1,3 +1,28 @@
|
||||||
|
2003-04-13 Michael Hanni <michael@deviant-behavior.com>
|
||||||
|
|
||||||
|
Multiple outstanding commits.
|
||||||
|
|
||||||
|
* ColorPickers/GSWheelColorPicker.m:
|
||||||
|
(mouseDown:): Implemented new event loop that really speeds things
|
||||||
|
up on slow machines.
|
||||||
|
* Source/NSScroller.m:
|
||||||
|
(init): Decreased periodic delay for scroller buttons.
|
||||||
|
(trackKnob:): Implemented new event loop to improve speed. Added
|
||||||
|
code to "snap" back the scroller when you release the alternate
|
||||||
|
key in mid-scroll (modeled after OS 4.2 behavior.)
|
||||||
|
(trackScrollButtons:): Removed event loop as we weren't using it
|
||||||
|
anyways.
|
||||||
|
* Source/NSFontPanel.m:
|
||||||
|
(_trySelectSize:): Put size textfield update code here, make sure
|
||||||
|
column is loaded.
|
||||||
|
(_familySelectionChanged:): Call _trySelectSize: to update the
|
||||||
|
size column just like we do for the face browser.
|
||||||
|
* Source/NSProgressIndicator.m:
|
||||||
|
(drawRect:): Implement GSGtkInterfaceStyle for
|
||||||
|
NSProgressIndicatorInterfaceStyle.
|
||||||
|
* Source/NSInterfaceStyle.m: added GSGtkInterfaceStyle.
|
||||||
|
* Headers/NSInterfaceStyle.h: ditto.
|
||||||
|
|
||||||
2003-04-13 Michael Hanni <michael@deviant-behavior.com>
|
2003-04-13 Michael Hanni <michael@deviant-behavior.com>
|
||||||
|
|
||||||
* Source/NSPopUpButton.m:
|
* Source/NSPopUpButton.m:
|
||||||
|
|
|
@ -148,17 +148,14 @@
|
||||||
PSrectfill(x - 1, y - 1, 2, 2);
|
PSrectfill(x - 1, y - 1, 2, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (void) mouseDown: (NSEvent *)theEvent
|
- (void) mouseDown: (NSEvent *)theEvent
|
||||||
{
|
{
|
||||||
NSApplication *app = [NSApplication sharedApplication];
|
|
||||||
unsigned int eventMask = NSLeftMouseDownMask | NSLeftMouseUpMask
|
unsigned int eventMask = NSLeftMouseDownMask | NSLeftMouseUpMask
|
||||||
| NSLeftMouseDraggedMask | NSMouseMovedMask
|
| NSLeftMouseDraggedMask;
|
||||||
| NSPeriodicMask;
|
|
||||||
NSPoint point = [self convertPoint: [theEvent locationInWindow]
|
NSPoint point = [self convertPoint: [theEvent locationInWindow]
|
||||||
fromView: nil];
|
fromView: nil];
|
||||||
NSEventType eventType = [theEvent type];
|
NSEventType eventType = [theEvent type];
|
||||||
NSDate *distantFuture = [NSDate distantFuture];
|
NSEvent *presentEvent;
|
||||||
|
|
||||||
float new_hue, new_saturation;
|
float new_hue, new_saturation;
|
||||||
float old_x, old_y;
|
float old_x, old_y;
|
||||||
|
@ -173,64 +170,79 @@
|
||||||
cr = frame.size.height;
|
cr = frame.size.height;
|
||||||
cr = cr / 2 - 2;
|
cr = cr / 2 - 2;
|
||||||
|
|
||||||
|
|
||||||
[NSEvent startPeriodicEventsAfterDelay: 0.05 withPeriod: 0.05];
|
|
||||||
[[NSRunLoop currentRunLoop] limitDateForMode: NSEventTrackingRunLoopMode];
|
|
||||||
|
|
||||||
new_hue = hue;
|
new_hue = hue;
|
||||||
new_saturation = saturation;
|
new_saturation = saturation;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (eventType != NSPeriodic)
|
/* Inner loop that gets and (quickly) handles all events that have
|
||||||
{
|
already arrived. */
|
||||||
point = [self convertPoint: [theEvent locationInWindow]
|
while (theEvent && eventType != NSLeftMouseUp)
|
||||||
fromView: nil];
|
{
|
||||||
|
/* Note the event here. Don't do any expensive handling. */
|
||||||
|
presentEvent = theEvent;
|
||||||
|
|
||||||
dx = point.x - cx;
|
theEvent = [NSApp nextEventMatchingMask: eventMask
|
||||||
dy = point.y - cy;
|
untilDate: [NSDate distantPast] /* Only get events that have arrived */
|
||||||
|
inMode: NSEventTrackingRunLoopMode
|
||||||
|
dequeue: YES];
|
||||||
|
eventType = [theEvent type];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* No more events right now. Do expensive handling, like drawing,
|
||||||
|
* here.
|
||||||
|
*/
|
||||||
|
point = [self convertPoint: [presentEvent locationInWindow]
|
||||||
|
fromView: nil];
|
||||||
|
|
||||||
new_saturation = dx * dx + dy * dy;
|
dx = point.x - cx;
|
||||||
new_saturation = sqrt(new_saturation);
|
dy = point.y - cy;
|
||||||
new_saturation /= cr;
|
|
||||||
if (new_saturation > 1)
|
|
||||||
new_saturation = 1;
|
|
||||||
|
|
||||||
new_hue = atan2(dy, dx);
|
new_saturation = dx * dx + dy * dy;
|
||||||
new_hue = new_hue / 2.0 / PI;
|
new_saturation = sqrt(new_saturation);
|
||||||
if (new_hue < 0)
|
new_saturation /= cr;
|
||||||
new_hue += 1;
|
if (new_saturation > 1)
|
||||||
}
|
new_saturation = 1;
|
||||||
else
|
|
||||||
{
|
|
||||||
if (new_hue != hue || new_saturation != saturation)
|
|
||||||
{
|
|
||||||
old_x = cos(hue * 2 * PI) * saturation * cr + cx;
|
|
||||||
old_y = sin(hue * 2 * PI) * saturation * cr + cy;
|
|
||||||
|
|
||||||
hue = new_hue;
|
new_hue = atan2(dy, dx);
|
||||||
saturation = new_saturation;
|
new_hue = new_hue / 2.0 / PI;
|
||||||
|
if (new_hue < 0)
|
||||||
|
new_hue += 1;
|
||||||
|
|
||||||
[self lockFocus];
|
if (new_hue != hue || new_saturation != saturation)
|
||||||
[self drawRect: NSMakeRect(old_x - 3, old_y - 3, 6, 6)];
|
{
|
||||||
[self drawRect: NSMakeRect(point.x - 3, point.y - 3, 6, 6)];
|
old_x = cos(hue * 2 * PI) * saturation * cr + cx;
|
||||||
[self unlockFocus];
|
old_y = sin(hue * 2 * PI) * saturation * cr + cy;
|
||||||
[_window flushWindow];
|
|
||||||
|
|
||||||
if (target)
|
hue = new_hue;
|
||||||
[target performSelector: action withObject: self];
|
saturation = new_saturation;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
theEvent = [app nextEventMatchingMask: eventMask
|
[self lockFocus];
|
||||||
untilDate: distantFuture
|
[self drawRect: NSMakeRect(old_x - 3, old_y - 3, 6, 6)];
|
||||||
inMode: NSEventTrackingRunLoopMode
|
[self drawRect: NSMakeRect(point.x - 3, point.y - 3, 6, 6)];
|
||||||
dequeue: YES];
|
[self unlockFocus];
|
||||||
eventType = [theEvent type];
|
[_window flushWindow];
|
||||||
} while (eventType != NSLeftMouseUp);
|
|
||||||
[NSEvent stopPeriodicEvents];
|
if (target)
|
||||||
|
[target performSelector: action withObject: self];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If our current event is actually the mouse up (perhaps the inner
|
||||||
|
* loop got to this point) we want to update with the last info and
|
||||||
|
* then quit.
|
||||||
|
*/
|
||||||
|
if (eventType == NSLeftMouseUp)
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* Get the next event, blocking if necessary. */
|
||||||
|
theEvent = [NSApp nextEventMatchingMask: eventMask
|
||||||
|
untilDate: nil /* No limit, block until we get an event. */
|
||||||
|
inMode: NSEventTrackingRunLoopMode
|
||||||
|
dequeue: YES];
|
||||||
|
eventType = [theEvent type];
|
||||||
|
} while (eventType != NSLeftMouseUp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -44,8 +44,8 @@ typedef enum {
|
||||||
* GNUstep specific. Blame: Michael Hanni.
|
* GNUstep specific. Blame: Michael Hanni.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
GSWindowMakerInterfaceStyle = 4
|
GSWindowMakerInterfaceStyle = 4,
|
||||||
|
GSGtkInterfaceStyle = 5
|
||||||
} NSInterfaceStyle;
|
} NSInterfaceStyle;
|
||||||
|
|
||||||
APPKIT_EXPORT NSString *NSInterfaceStyleDefault;
|
APPKIT_EXPORT NSString *NSInterfaceStyleDefault;
|
||||||
|
|
|
@ -209,7 +209,6 @@ static float sizes[] = {4.0, 6.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0,
|
||||||
NSString *family = [fontObject familyName];
|
NSString *family = [fontObject familyName];
|
||||||
NSString *fontName = [fontObject fontName];
|
NSString *fontName = [fontObject fontName];
|
||||||
float size = [fontObject pointSize];
|
float size = [fontObject pointSize];
|
||||||
NSTextField *sizeField = [[self contentView] viewWithTag: NSFPSizeField];
|
|
||||||
NSBrowser *familyBrowser = [[self contentView] viewWithTag: NSFPFamilyBrowser];
|
NSBrowser *familyBrowser = [[self contentView] viewWithTag: NSFPFamilyBrowser];
|
||||||
NSBrowser *faceBrowser = [[self contentView] viewWithTag: NSFPFaceBrowser];
|
NSBrowser *faceBrowser = [[self contentView] viewWithTag: NSFPFaceBrowser];
|
||||||
NSString *face = @"";
|
NSString *face = @"";
|
||||||
|
@ -249,7 +248,6 @@ static float sizes[] = {4.0, 6.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0,
|
||||||
}
|
}
|
||||||
|
|
||||||
// show point size and select the row if there is one
|
// show point size and select the row if there is one
|
||||||
_setFloatValue (sizeField, size);
|
|
||||||
[self _trySelectSize: size];
|
[self _trySelectSize: size];
|
||||||
|
|
||||||
// Use in preview
|
// Use in preview
|
||||||
|
@ -733,11 +731,20 @@ static float sizes[] = {4.0, 6.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0,
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
NSBrowser *sizeBrowser = [[self contentView] viewWithTag: NSFPSizeBrowser];
|
NSBrowser *sizeBrowser = [[self contentView] viewWithTag: NSFPSizeBrowser];
|
||||||
|
NSTextField *sizeField;
|
||||||
|
|
||||||
|
/* Make sure our sizeField is updated. */
|
||||||
|
sizeField = [[self contentView] viewWithTag: NSFPSizeField];
|
||||||
|
_setFloatValue (sizeField, size);
|
||||||
|
|
||||||
|
/* Make sure our column is loaded. */
|
||||||
|
[sizeBrowser loadColumnZero];
|
||||||
|
|
||||||
for (i = 0; i < sizeof(sizes) / sizeof(float); i++)
|
for (i = 0; i < sizeof(sizes) / sizeof(float); i++)
|
||||||
{
|
{
|
||||||
if (size == sizes[i])
|
if (size == sizes[i])
|
||||||
{
|
{
|
||||||
|
/* select the cell */
|
||||||
[sizeBrowser selectRow: i inColumn: 0];
|
[sizeBrowser selectRow: i inColumn: 0];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -840,6 +847,9 @@ static int score_difference(int weight1, int traits1,
|
||||||
[faceBrowser loadColumnZero];
|
[faceBrowser loadColumnZero];
|
||||||
[faceBrowser selectRow: i inColumn: 0];
|
[faceBrowser selectRow: i inColumn: 0];
|
||||||
|
|
||||||
|
/* Also make sure the size column is updated */
|
||||||
|
[self _trySelectSize: [[self _fontForSelection: _panelFont] pointSize]];
|
||||||
|
|
||||||
[self _doPreview];
|
[self _doPreview];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,8 @@ styleFromString(NSString* str)
|
||||||
return NSMacintoshInterfaceStyle;
|
return NSMacintoshInterfaceStyle;
|
||||||
if ([str isEqualToString: @"NSWindows95InterfaceStyle"])
|
if ([str isEqualToString: @"NSWindows95InterfaceStyle"])
|
||||||
return NSWindows95InterfaceStyle;
|
return NSWindows95InterfaceStyle;
|
||||||
|
if ([str isEqualToString: @"GSGtkInterfaceStyle"])
|
||||||
|
return GSGtkInterfaceStyle;
|
||||||
if ([str isEqualToString: @"GSWindowMakerInterfaceStyle"])
|
if ([str isEqualToString: @"GSWindowMakerInterfaceStyle"])
|
||||||
return GSWindowMakerInterfaceStyle;
|
return GSWindowMakerInterfaceStyle;
|
||||||
return NSNoInterfaceStyle;
|
return NSNoInterfaceStyle;
|
||||||
|
|
|
@ -258,8 +258,31 @@ NSImage *images[maxCount];
|
||||||
r = NSIntersectionRect(r,rect);
|
r = NSIntersectionRect(r,rect);
|
||||||
if (!NSIsEmptyRect(r))
|
if (!NSIsEmptyRect(r))
|
||||||
{
|
{
|
||||||
[fillColour set];
|
if (NSInterfaceStyleForKey(@"NSProgressIndicatorInterfaceStyle", nil)
|
||||||
NSRectFill(r);
|
== GSGtkInterfaceStyle)
|
||||||
|
{
|
||||||
|
NSRectEdge sides[] = {NSMaxXEdge, NSMinYEdge,
|
||||||
|
NSMinXEdge, NSMaxYEdge,
|
||||||
|
NSMaxXEdge, NSMinYEdge};
|
||||||
|
float grays[] = {NSBlack, NSBlack,
|
||||||
|
NSLightGray, NSLightGray,
|
||||||
|
NSDarkGray, NSDarkGray};
|
||||||
|
NSRect rect;
|
||||||
|
|
||||||
|
rect = NSDrawTiledRects(r, r,
|
||||||
|
sides, grays, 6);
|
||||||
|
|
||||||
|
/* This should perhaps be something else to ease in
|
||||||
|
* color themeing.
|
||||||
|
*/
|
||||||
|
[[NSColor scrollBarColor] set];
|
||||||
|
NSRectFill(rect);
|
||||||
|
}
|
||||||
|
else /* default case */
|
||||||
|
{
|
||||||
|
[fillColour set];
|
||||||
|
NSRectFill(r);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -243,7 +243,7 @@ static NSColor *scrollBarColor = nil;
|
||||||
[upCell setImagePosition: NSImageOnly];
|
[upCell setImagePosition: NSImageOnly];
|
||||||
[upCell setContinuous: YES];
|
[upCell setContinuous: YES];
|
||||||
[upCell sendActionOn: (NSLeftMouseDownMask | NSPeriodicMask)];
|
[upCell sendActionOn: (NSLeftMouseDownMask | NSPeriodicMask)];
|
||||||
[upCell setPeriodicDelay: 0.3 interval: 0.04];
|
[upCell setPeriodicDelay: 0.3 interval: 0.03];
|
||||||
|
|
||||||
downCell = [NSButtonCell new];
|
downCell = [NSButtonCell new];
|
||||||
[downCell setHighlightsBy: NSChangeBackgroundCellMask|NSContentsCellMask];
|
[downCell setHighlightsBy: NSChangeBackgroundCellMask|NSContentsCellMask];
|
||||||
|
@ -252,7 +252,7 @@ static NSColor *scrollBarColor = nil;
|
||||||
[downCell setImagePosition: NSImageOnly];
|
[downCell setImagePosition: NSImageOnly];
|
||||||
[downCell setContinuous: YES];
|
[downCell setContinuous: YES];
|
||||||
[downCell sendActionOn: (NSLeftMouseDownMask | NSPeriodicMask)];
|
[downCell sendActionOn: (NSLeftMouseDownMask | NSPeriodicMask)];
|
||||||
[downCell setPeriodicDelay: 0.3 interval: 0.04];
|
[downCell setPeriodicDelay: 0.3 interval: 0.03];
|
||||||
|
|
||||||
leftCell = [NSButtonCell new];
|
leftCell = [NSButtonCell new];
|
||||||
[leftCell setHighlightsBy: NSChangeBackgroundCellMask|NSContentsCellMask];
|
[leftCell setHighlightsBy: NSChangeBackgroundCellMask|NSContentsCellMask];
|
||||||
|
@ -261,7 +261,7 @@ static NSColor *scrollBarColor = nil;
|
||||||
[leftCell setImagePosition: NSImageOnly];
|
[leftCell setImagePosition: NSImageOnly];
|
||||||
[leftCell setContinuous: YES];
|
[leftCell setContinuous: YES];
|
||||||
[leftCell sendActionOn: (NSLeftMouseDownMask | NSPeriodicMask)];
|
[leftCell sendActionOn: (NSLeftMouseDownMask | NSPeriodicMask)];
|
||||||
[leftCell setPeriodicDelay: 0.3 interval: 0.04];
|
[leftCell setPeriodicDelay: 0.3 interval: 0.03];
|
||||||
|
|
||||||
rightCell = [NSButtonCell new];
|
rightCell = [NSButtonCell new];
|
||||||
[rightCell setHighlightsBy: NSChangeBackgroundCellMask|NSContentsCellMask];
|
[rightCell setHighlightsBy: NSChangeBackgroundCellMask|NSContentsCellMask];
|
||||||
|
@ -270,7 +270,7 @@ static NSColor *scrollBarColor = nil;
|
||||||
[rightCell setImagePosition: NSImageOnly];
|
[rightCell setImagePosition: NSImageOnly];
|
||||||
[rightCell setContinuous: YES];
|
[rightCell setContinuous: YES];
|
||||||
[rightCell sendActionOn: (NSLeftMouseDownMask | NSPeriodicMask)];
|
[rightCell sendActionOn: (NSLeftMouseDownMask | NSPeriodicMask)];
|
||||||
[rightCell setPeriodicDelay: 0.3 interval: 0.04];
|
[rightCell setPeriodicDelay: 0.3 interval: 0.03];
|
||||||
|
|
||||||
knobCell = [NSButtonCell new];
|
knobCell = [NSButtonCell new];
|
||||||
[knobCell setButtonType: NSMomentaryChangeButton];
|
[knobCell setButtonType: NSMomentaryChangeButton];
|
||||||
|
@ -583,23 +583,21 @@ static NSColor *scrollBarColor = nil;
|
||||||
- (void) trackKnob: (NSEvent*)theEvent
|
- (void) trackKnob: (NSEvent*)theEvent
|
||||||
{
|
{
|
||||||
unsigned int eventMask = NSLeftMouseDownMask | NSLeftMouseUpMask
|
unsigned int eventMask = NSLeftMouseDownMask | NSLeftMouseUpMask
|
||||||
| NSLeftMouseDraggedMask | NSMouseMovedMask
|
| NSLeftMouseDraggedMask | NSFlagsChangedMask;
|
||||||
| NSPeriodicMask;
|
|
||||||
NSPoint point;
|
NSPoint point;
|
||||||
NSPoint apoint;
|
|
||||||
float lastPosition;
|
float lastPosition;
|
||||||
float newPosition;
|
float newPosition;
|
||||||
float floatValue;
|
float floatValue;
|
||||||
float offset;
|
float offset;
|
||||||
NSDate *theDistantFuture = [NSDate distantFuture];
|
float initialOffset;
|
||||||
NSEventType eventType;
|
NSEvent *presentEvent;
|
||||||
|
NSEventType eventType = [theEvent type];
|
||||||
NSRect knobRect;
|
NSRect knobRect;
|
||||||
unsigned flags = [theEvent modifierFlags];
|
unsigned flags = [theEvent modifierFlags];
|
||||||
|
|
||||||
knobRect = [self rectForPart: NSScrollerKnob];
|
knobRect = [self rectForPart: NSScrollerKnob];
|
||||||
|
|
||||||
apoint = [theEvent locationInWindow];
|
point = [self convertPoint: [theEvent locationInWindow] fromView: nil];
|
||||||
point = [self convertPoint: apoint fromView: nil];
|
|
||||||
if (_isHorizontal)
|
if (_isHorizontal)
|
||||||
{
|
{
|
||||||
lastPosition = NSMidX(knobRect);
|
lastPosition = NSMidX(knobRect);
|
||||||
|
@ -611,138 +609,152 @@ static NSColor *scrollBarColor = nil;
|
||||||
offset = lastPosition - point.y;
|
offset = lastPosition - point.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
initialOffset = offset; /* Save the initial offset value */
|
||||||
_hitPart = NSScrollerKnob;
|
_hitPart = NSScrollerKnob;
|
||||||
/*
|
|
||||||
* set periodic events rate to achieve max of ~30fps
|
|
||||||
*/
|
|
||||||
[NSEvent startPeriodicEventsAfterDelay: 0.02 withPeriod: 0.03];
|
|
||||||
[[NSRunLoop currentRunLoop] limitDateForMode: NSEventTrackingRunLoopMode];
|
|
||||||
|
|
||||||
while ((eventType = [theEvent type]) != NSLeftMouseUp)
|
do
|
||||||
{
|
{
|
||||||
CREATE_AUTORELEASE_POOL(arp);
|
/* Inner loop that gets and (quickly) handles all events that have
|
||||||
if (eventType != NSPeriodic)
|
already arrived. */
|
||||||
{
|
while (theEvent && eventType != NSLeftMouseUp)
|
||||||
apoint = [theEvent locationInWindow];
|
{
|
||||||
flags = [theEvent modifierFlags];
|
/* Note the event here. Don't do any expensive handling. */
|
||||||
}
|
if (eventType == NSFlagsChanged)
|
||||||
else
|
flags = [theEvent modifierFlags];
|
||||||
{
|
presentEvent = theEvent;
|
||||||
point = [self convertPoint: apoint fromView: nil];
|
|
||||||
if (_isHorizontal)
|
|
||||||
newPosition = point.x + offset;
|
|
||||||
else
|
|
||||||
newPosition = point.y + offset;
|
|
||||||
|
|
||||||
if (newPosition != lastPosition)
|
theEvent = [NSApp nextEventMatchingMask: eventMask
|
||||||
{
|
untilDate: [NSDate distantPast] /* Only get events that have already arrived. */
|
||||||
if (flags & NSAlternateKeyMask)
|
inMode: NSEventTrackingRunLoopMode
|
||||||
{
|
dequeue: YES];
|
||||||
float diff;
|
eventType = [theEvent type];
|
||||||
|
}
|
||||||
|
|
||||||
diff = newPosition - lastPosition;
|
/*
|
||||||
diff = diff * 3 / 4;
|
* No more events right now. Do expensive handling, like drawing,
|
||||||
offset -= diff;
|
* here.
|
||||||
newPosition -= diff;
|
*/
|
||||||
}
|
point = [self convertPoint: [presentEvent locationInWindow]
|
||||||
|
fromView: nil];
|
||||||
|
|
||||||
// only one coordinate (X or Y) is used to compute floatValue.
|
if (_isHorizontal)
|
||||||
point = NSMakePoint(newPosition, newPosition);
|
newPosition = point.x + offset;
|
||||||
floatValue = [self _floatValueForMousePoint: point];
|
else
|
||||||
|
newPosition = point.y + offset;
|
||||||
|
|
||||||
if (floatValue != _floatValue)
|
if (newPosition != lastPosition)
|
||||||
{
|
{
|
||||||
[self setFloatValue: floatValue];
|
if (flags & NSAlternateKeyMask)
|
||||||
[self sendAction: _action to: _target];
|
{
|
||||||
}
|
float diff;
|
||||||
|
|
||||||
|
diff = newPosition - lastPosition;
|
||||||
|
diff = diff * 3 / 4;
|
||||||
|
offset -= diff;
|
||||||
|
newPosition -= diff;
|
||||||
|
}
|
||||||
|
else /* Ok, we are no longer doing slow scrolling, lets go back
|
||||||
|
to our original offset. */
|
||||||
|
{
|
||||||
|
offset = initialOffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
// only one coordinate (X or Y) is used to compute floatValue.
|
||||||
|
point = NSMakePoint(newPosition, newPosition);
|
||||||
|
floatValue = [self _floatValueForMousePoint: point];
|
||||||
|
|
||||||
|
if (floatValue != _floatValue)
|
||||||
|
{
|
||||||
|
[self setFloatValue: floatValue];
|
||||||
|
[self sendAction: _action to: _target];
|
||||||
|
}
|
||||||
|
|
||||||
lastPosition = newPosition;
|
lastPosition = newPosition;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
theEvent = [NSApp nextEventMatchingMask: eventMask
|
/*
|
||||||
untilDate: theDistantFuture
|
* If our current event is actually the mouse up (perhaps the inner
|
||||||
inMode: NSEventTrackingRunLoopMode
|
* loop got to this point) we want to update with the last info and
|
||||||
dequeue: YES];
|
* then quit.
|
||||||
DESTROY(arp);
|
*/
|
||||||
}
|
if (eventType == NSLeftMouseUp)
|
||||||
[NSEvent stopPeriodicEvents];
|
break;
|
||||||
|
|
||||||
|
/* Get the next event, blocking if necessary. */
|
||||||
|
theEvent = [NSApp nextEventMatchingMask: eventMask
|
||||||
|
untilDate: nil /* No limit, block until we get an event. */
|
||||||
|
inMode: NSEventTrackingRunLoopMode
|
||||||
|
dequeue: YES];
|
||||||
|
eventType = [theEvent type];
|
||||||
|
} while (eventType != NSLeftMouseUp);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) trackScrollButtons: (NSEvent*)theEvent
|
- (void) trackScrollButtons: (NSEvent*)theEvent
|
||||||
{
|
{
|
||||||
NSApplication *theApp = [NSApplication sharedApplication];
|
|
||||||
unsigned int eventMask = NSLeftMouseDownMask | NSLeftMouseUpMask |
|
|
||||||
NSLeftMouseDraggedMask | NSMouseMovedMask;
|
|
||||||
BOOL shouldReturn = NO;
|
|
||||||
id theCell = nil;
|
id theCell = nil;
|
||||||
NSRect rect;
|
NSRect rect;
|
||||||
|
|
||||||
[self lockFocus];
|
[self lockFocus];
|
||||||
|
|
||||||
NSDebugLog (@"trackScrollButtons");
|
NSDebugLog (@"trackScrollButtons");
|
||||||
do
|
|
||||||
|
_hitPart = [self testPart: [theEvent locationInWindow]];
|
||||||
|
rect = [self rectForPart: _hitPart];
|
||||||
|
|
||||||
|
/*
|
||||||
|
* A hit on a scroller button should be a page movement
|
||||||
|
* if the alt key is pressed.
|
||||||
|
*/
|
||||||
|
switch (_hitPart)
|
||||||
{
|
{
|
||||||
_hitPart = [self testPart: [theEvent locationInWindow]];
|
case NSScrollerIncrementLine:
|
||||||
rect = [self rectForPart: _hitPart];
|
if ([theEvent modifierFlags] & NSAlternateKeyMask)
|
||||||
|
{
|
||||||
/*
|
_hitPart = NSScrollerIncrementPage;
|
||||||
* A hit on a scroller button should be a page movement
|
}
|
||||||
* if the alt key is pressed.
|
/* Fall through to next case */
|
||||||
*/
|
case NSScrollerIncrementPage:
|
||||||
switch (_hitPart)
|
theCell = (_isHorizontal ? rightCell : downCell);
|
||||||
{
|
|
||||||
case NSScrollerIncrementLine:
|
|
||||||
if ([theEvent modifierFlags] & NSAlternateKeyMask)
|
|
||||||
{
|
|
||||||
_hitPart = NSScrollerIncrementPage;
|
|
||||||
}
|
|
||||||
/* Fall through to next case */
|
|
||||||
case NSScrollerIncrementPage:
|
|
||||||
theCell = (_isHorizontal ? rightCell : downCell);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NSScrollerDecrementLine:
|
|
||||||
if ([theEvent modifierFlags] & NSAlternateKeyMask)
|
|
||||||
{
|
|
||||||
_hitPart = NSScrollerDecrementPage;
|
|
||||||
}
|
|
||||||
/* Fall through to next case */
|
|
||||||
case NSScrollerDecrementPage:
|
|
||||||
theCell = (_isHorizontal ? leftCell : upCell);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
theCell = nil;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (theCell)
|
|
||||||
{
|
|
||||||
[theCell highlight: YES withFrame: rect inView: self];
|
|
||||||
[_window flushWindow];
|
|
||||||
|
|
||||||
NSDebugLog (@"tracking cell %x", theCell);
|
|
||||||
|
|
||||||
shouldReturn = [theCell trackMouse: theEvent
|
|
||||||
inRect: rect
|
|
||||||
ofView: self
|
|
||||||
untilMouseUp: YES];
|
|
||||||
|
|
||||||
[theCell highlight: NO withFrame: rect inView: self];
|
|
||||||
[_window flushWindow];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (shouldReturn)
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
theEvent = [theApp nextEventMatchingMask: eventMask
|
case NSScrollerDecrementLine:
|
||||||
untilDate: [NSDate distantFuture]
|
if ([theEvent modifierFlags] & NSAlternateKeyMask)
|
||||||
inMode: NSEventTrackingRunLoopMode
|
{
|
||||||
dequeue: YES];
|
_hitPart = NSScrollerDecrementPage;
|
||||||
}
|
}
|
||||||
while ([theEvent type] != NSLeftMouseUp);
|
/* Fall through to next case */
|
||||||
|
case NSScrollerDecrementPage:
|
||||||
|
theCell = (_isHorizontal ? leftCell : upCell);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
theCell = nil;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If we don't find a cell this has been all for naught, but we
|
||||||
|
* shouldn't ever be in that situation.
|
||||||
|
*/
|
||||||
|
if (theCell)
|
||||||
|
{
|
||||||
|
[theCell highlight: YES withFrame: rect inView: self];
|
||||||
|
[_window flushWindow];
|
||||||
|
|
||||||
|
NSDebugLog (@"tracking cell %x", theCell);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The "tracking" in this method actually takes place within
|
||||||
|
* NSCell's trackMouse: method.
|
||||||
|
*/
|
||||||
|
[theCell trackMouse: theEvent
|
||||||
|
inRect: rect
|
||||||
|
ofView: self
|
||||||
|
untilMouseUp: YES];
|
||||||
|
|
||||||
|
[theCell highlight: NO withFrame: rect inView: self];
|
||||||
|
[_window flushWindow];
|
||||||
|
}
|
||||||
[self unlockFocus];
|
[self unlockFocus];
|
||||||
|
|
||||||
NSDebugLog (@"return from trackScrollButtons");
|
NSDebugLog (@"return from trackScrollButtons");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue