gui changes

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@3164 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
far 1998-11-02 17:42:23 +00:00
parent 00bc3151f2
commit 65a0194e32
7 changed files with 556 additions and 660 deletions

View file

@ -63,6 +63,7 @@ extern NSString *NSEventTrackingRunLoopMode;
// Attributes
NSMutableArray *window_list;
NSMutableArray *event_queue;
NSMutableArray *recycled_event_queue;
NSEvent *current_event;
id key_window;
id main_window;
@ -78,6 +79,8 @@ extern NSString *NSEventTrackingRunLoopMode;
BOOL windows_need_update;
NSImage *app_icon;
BOOL inTrackingLoop;
// Reserved for back-end use
void *be_app_reserved;
}
@ -132,12 +135,6 @@ extern NSString *NSEventTrackingRunLoopMode;
dequeue:(BOOL)flag;
- (void)postEvent:(NSEvent *)event atStart:(BOOL)flag;
// xxx Not part of OpenStep, should be removed someday
- (NSEvent *)peekEventMatchingMask:(unsigned int)mask
untilDate:(NSDate *)expiration
inMode:(NSString *)mode
dequeue:(BOOL)flag;
//
// Sending action messages
//
@ -271,15 +268,10 @@ extern NSString *NSEventTrackingRunLoopMode;
+ (void)setNullEvent:(NSEvent *)e;
+ (NSEvent *)getNullEvent;
// Get next event
- (void)getNextEvent;
- (NSEvent *)peekNextEvent;
// handle a non-translated event
- (void)handleNullEvent;
/* Private methods */
- (void)_flushCommunicationChannels;
// Get next event
- (void)_nextEvent;
@end

View file

@ -77,27 +77,22 @@ static id NSApp;
if (self == [NSApplication class])
{
NSDebugLog(@"Initialize NSApplication class\n");
// Initial version
[self setVersion:1];
// So the application knows its within dealloc
// and can prevent -release loops.
gnustep_gui_app_is_in_dealloc = NO;
}
}
// So the application knows
gnustep_gui_app_is_in_dealloc = NO; // its within dealloc and
} // can prevent -release
} // loops.
+ (NSApplication *)sharedApplication
{ // If the global application does
if (!NSApp) // not exist yet then create it
{
// If the global application does not exist yet then create it
if (!NSApp) {
/* Don't combine the following two statements into one to avoid problems
with some classes initialization code that tries to get the shared
application. */
NSApp = [self alloc];
[NSApp init];
}
return NSApp;
NSApp = [self alloc]; // Don't combine the following two
[NSApp init]; // statements into one to avoid
} // problems with some classes'
// initialization code that tries
return NSApp; // to get the shared application.
}
//
@ -113,28 +108,23 @@ static id NSApp;
NSDebugLog(@"Begin of NSApplication -init\n");
// allocate the window list
window_list = [NSMutableArray new];
window_list = [NSMutableArray new]; // allocate window list
window_count = 1;
main_menu = nil;
windows_need_update = YES;
//
// Event handling setup
//
// allocate the event queue
event_queue = [NSMutableArray new];
// No current event
current_event = nil;
// The NULL event
gnustep_gui_null_event = [NSEvent new];
//
// We are the end of the responder chain
//
[self setNextResponder:NULL];
event_queue = [NSMutableArray new]; // allocate event queue
recycled_event_queue = [NSMutableArray new]; // alloc recycle queue
current_event = [NSEvent new]; // no current event
gnustep_gui_null_event = [NSEvent new]; // create a NULL event
/* Set up the run loop object for the current thread */
[self setNextResponder:NULL]; // We are the end of
// the responder chain
// Set up the run loop
// object for the
// current thread
[self setupRunLoopInputSourcesForMode:NSDefaultRunLoopMode];
[self setupRunLoopInputSourcesForMode:NSConnectionReplyMode];
[self setupRunLoopInputSourcesForMode:NSModalPanelRunLoopMode];
@ -148,25 +138,27 @@ static id NSApp;
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
NSBundle* mainBundle = [NSBundle mainBundle];
NSString* resourcePath = [mainBundle resourcePath];
NSString* infoFilePath
= [resourcePath stringByAppendingPathComponent:@"Info-gnustep.plist"];
NSDictionary* infoDict = [[NSString stringWithContentsOfFile:infoFilePath]
propertyList];
NSString* mainModelFile = [infoDict objectForKey:@"NSMainNibFile"];
NSString* infoFilePath = [resourcePath
stringByAppendingPathComponent:@"Info-gnustep.plist"];
NSDictionary* infoDict;
NSString* mainModelFile;
if (mainModelFile && ![mainModelFile isEqual:@""]) {
infoDict = [[NSString stringWithContentsOfFile:infoFilePath] propertyList];
mainModelFile = [infoDict objectForKey:@"NSMainNibFile"];
if (mainModelFile && ![mainModelFile isEqual:@""])
{
if (![GMModel loadIMFile:mainModelFile
owner:[NSApplication sharedApplication]])
NSLog (@"Cannot load the main model file '%@", mainModelFile);
}
// notify that we will finish the launching
// post notification that
// launch will finish
[nc postNotificationName: NSApplicationWillFinishLaunchingNotification
object: self];
// finish the launching
// notify that the launching has finished
// post notification that
// launching has finished
[nc postNotificationName: NSApplicationDidFinishLaunchingNotification
object: self];
}
@ -174,12 +166,12 @@ static id NSApp;
- (void)dealloc
{
NSDebugLog(@"Freeing NSApplication\n");
// Let ourselves know we are within dealloc
gnustep_gui_app_is_in_dealloc = YES;
// Let ourselves know we
gnustep_gui_app_is_in_dealloc = YES; // are within dealloc
[window_list release];
[event_queue release];
[recycled_event_queue release];
[current_event release];
[super dealloc];
}
@ -244,8 +236,6 @@ NSAutoreleasePool* pool;
dequeue:YES];
if (e)
[self sendEvent: e];
else // if Null event call back
[self handleNullEvent]; // end method to handle it
if(windows_need_update) // send an update message
[self updateWindows]; // to all visible windows
@ -261,6 +251,7 @@ NSAutoreleasePool* pool;
{
[theWindow display];
[theWindow makeKeyAndOrderFront: self];
return 0;
}
@ -271,22 +262,16 @@ NSAutoreleasePool* pool;
- (void)sendEvent:(NSEvent *)theEvent
{
// Don't send the null event
if (theEvent == gnustep_gui_null_event)
if (theEvent == gnustep_gui_null_event) // Don't send null event
{
NSDebugLog(@"Not sending the Null Event\n");
return;
}
// What is the event type
switch ([theEvent type])
switch ([theEvent type]) // determine the event type
{
//
// NSApplication traps the periodic events
//
case NSPeriodic:
break;
case NSPeriodic: // NSApplication traps the
break; // periodic events
case NSKeyDown:
{
@ -294,20 +279,20 @@ NSAutoreleasePool* pool;
[[theEvent window] sendEvent:theEvent];
break;
}
case NSKeyUp:
{
NSDebugLog(@"send key up event\n");
[[theEvent window] sendEvent:theEvent];
break;
}
//
// All others get passed to the window
//
default:
{
default: // pass all other events to
{ // the event's window
NSWindow* window = [theEvent window];
if (!theEvent) NSDebugLog(@"NSEvent is nil!\n");
if (!theEvent)
NSDebugLog(@"NSEvent is nil!\n");
NSDebugLog(@"NSEvent type: %d", [theEvent type]);
NSDebugLog(@"send event to window");
NSDebugLog([window description]);
@ -334,95 +319,6 @@ NSAutoreleasePool* pool;
//
// Getting, removing, and posting events
//
- (BOOL)event:(NSEvent *)theEvent matchMask:(unsigned int)mask
{
if (mask == NSAnyEventMask) // If mask is for any event
return YES; // then return success
if (!theEvent)
return NO;
if (theEvent == gnustep_gui_null_event) // Don't check a null event
return NO;
switch([theEvent type])
{
case NSLeftMouseDown:
if (mask & NSLeftMouseDownMask)
return YES;
break;
case NSLeftMouseUp:
if (mask & NSLeftMouseUpMask)
return YES;
break;
case NSRightMouseDown:
if (mask & NSRightMouseDownMask)
return YES;
break;
case NSRightMouseUp:
if (mask & NSRightMouseUpMask)
return YES;
break;
case NSMouseMoved:
if (mask & NSMouseMovedMask)
return YES;
break;
case NSMouseEntered:
if (mask & NSMouseEnteredMask)
return YES;
break;
case NSMouseExited:
if (mask & NSMouseExitedMask)
return YES;
break;
case NSLeftMouseDragged:
if (mask & NSLeftMouseDraggedMask)
return YES;
break;
case NSRightMouseDragged:
if (mask & NSRightMouseDraggedMask)
return YES;
break;
case NSKeyDown:
if (mask & NSKeyDownMask)
return YES;
break;
case NSKeyUp:
if (mask & NSKeyUpMask)
return YES;
break;
case NSFlagsChanged:
if (mask & NSFlagsChangedMask)
return YES;
break;
case NSPeriodic:
if (mask & NSPeriodicMask)
return YES;
break;
case NSCursorUpdate:
if (mask & NSCursorUpdateMask)
return YES;
break;
default:
break;
}
return NO;
}
- (NSEvent *)currentEvent;
{
@ -434,61 +330,152 @@ NSAutoreleasePool* pool;
{
}
- (NSEvent*)_eventMatchingMask:(unsigned int)mask
{
NSEvent* event;
- (NSEvent*)_eventMatchingMask:(unsigned int)mask // return the next
{ // event in the queue
NSEvent* event; // which matches mask
int i, count;
BOOL match = NO;
[self getNextEvent];
[self _nextEvent];
if ((count = [event_queue count])) // Get an event from
{ // the events queue
//fprintf(stderr,"NSAppliation _eventMatchingMask: count %d\n", count);
for (i = 0; i < count; i++)
{
event = [event_queue objectAtIndex:i];
if ([self event:event matchMask:mask])
if (mask == NSAnyEventMask) // any event is a match
match = YES;
else
{
if (event == gnustep_gui_null_event) // do nothing if null
match = NO; // event
else
{
switch([event type])
{
case NSLeftMouseDown:
if (mask & NSLeftMouseDownMask)
match = YES;
break;
case NSLeftMouseUp:
if (mask & NSLeftMouseUpMask)
match = YES;
break;
case NSRightMouseDown:
if (mask & NSRightMouseDownMask)
match = YES;
break;
case NSRightMouseUp:
if (mask & NSRightMouseUpMask)
match = YES;
break;
case NSMouseMoved:
if (mask & NSMouseMovedMask)
match = YES;
break;
case NSMouseEntered:
if (mask & NSMouseEnteredMask)
match = YES;
break;
case NSMouseExited:
if (mask & NSMouseExitedMask)
match = YES;
break;
case NSLeftMouseDragged:
if (mask & NSLeftMouseDraggedMask)
match = YES;
break;
case NSRightMouseDragged:
if (mask & NSRightMouseDraggedMask)
match = YES;
break;
case NSKeyDown:
if (mask & NSKeyDownMask)
match = YES;
break;
case NSKeyUp:
if (mask & NSKeyUpMask)
match = YES;
break;
case NSFlagsChanged:
if (mask & NSFlagsChangedMask)
match = YES;
break;
case NSPeriodic:
if (mask & NSPeriodicMask)
match = YES;
break;
case NSCursorUpdate:
if (mask & NSCursorUpdateMask)
match = YES;
break;
default:
match = NO;
break;
}
}
}
if (match)
{
[event retain];
[event_queue removeObjectAtIndex:i];
ASSIGN(current_event, event);
return [event autorelease];
}
}
return [event autorelease]; // return an event from
} // the queue which
} // matches the mask
}
return nil;
}
return nil; // no event in the
} // queue matches mask
- (NSEvent *)nextEventMatchingMask:(unsigned int)mask
untilDate:(NSDate *)expiration
inMode:(NSString *)mode
dequeue:(BOOL)flag
{
NSRunLoop* currentLoop = [NSRunLoop currentRunLoop];
NSEventType type;
NSEvent *event;
BOOL done = NO;
event = [self _eventMatchingMask:mask];
if (event)
if(mode == NSEventTrackingRunLoopMode) // temporary hack to
inTrackingLoop = YES; // regulate translation
else // of X motion events
inTrackingLoop = NO; // while not in a
// tracking loop
if (event = [self _eventMatchingMask:mask])
done = YES;
else if (!expiration)
else
if (!expiration)
expiration = [NSDate distantFuture];
while (!done) // Not in queue so wait
{ // for next event
NSDate *limitDate, *originalLimitDate;
// Retain the limitDate so it doesn't get
// released accidentally by runMode:beforeDate:
// if a timer which has this date as fire date
// gets released.
NSRunLoop* currentLoop = [NSRunLoop currentRunLoop];
// Retain the limitDate so that it doesn't get released
// accidentally by runMode:beforeDate: if a timer which
// has this date as fire date gets released.
limitDate = [[currentLoop limitDateForMode:mode] retain];
originalLimitDate = limitDate;
event = [self _eventMatchingMask:mask];
if (event)
if (event = [self _eventMatchingMask:mask])
{
[limitDate release];
break;
@ -502,12 +489,12 @@ BOOL done = NO;
[currentLoop runMode:mode beforeDate:limitDate];
[originalLimitDate release];
event = [self _eventMatchingMask:mask];
if (event)
if (event = [self _eventMatchingMask:mask])
break;
}
// Unhide the cursor if necessary
if (event != gnustep_gui_null_event) // and event is not a null event
} // no need to unhide cursor
// while in a tracking loop
if (event != gnustep_gui_null_event && // or if event is the null
(!inTrackingLoop)) // event
{
if ([NSCursor isHiddenUntilMouseMoves]) // do so only if we should
{ // unhide when mouse moves
@ -515,45 +502,10 @@ BOOL done = NO;
if ((type == NSLeftMouseDown) || (type == NSLeftMouseUp)
|| (type == NSRightMouseDown) || (type == NSRightMouseUp)
|| (type == NSMouseMoved))
{
[NSCursor unhide];
}
}
return event;
}
- (NSEvent *)peekEventMatchingMask:(unsigned int)mask
untilDate:(NSDate *)expiration
inMode:(NSString *)mode
dequeue:(BOOL)flag
{
NSEvent *event = nil;
event = [self _eventMatchingMask:mask];
if (!event)
{
// Not in queue so peek for event
event = [self peekNextEvent];
event = [self _eventMatchingMask:mask];
}
// Unhide the cursor if necessary
if (event && (event != gnustep_gui_null_event))
{
NSEventType type;
// Only if we should unhide when mouse moves
if ([NSCursor isHiddenUntilMouseMoves])
{
// Make sure the event is a mouse event before unhiding
type = [event type];
if ((type == NSLeftMouseDown) || (type == NSLeftMouseUp)
|| (type == NSRightMouseDown) || (type == NSRightMouseUp)
|| (type == NSMouseMoved))
[NSCursor unhide];
}
}
return event;
@ -570,45 +522,32 @@ BOOL done = NO;
//
// Sending action messages
//
- (BOOL)sendAction:(SEL)aSelector
to:aTarget
from:sender
{
//
// If the target responds to the selector
// then have it perform it
//
if ([aTarget respondsToSelector:aSelector])
{
- (BOOL)sendAction:(SEL)aSelector to:aTarget from:sender
{ // If target responds
if ([aTarget respondsToSelector:aSelector]) // to the selector then
{ // have it perform it
[aTarget performSelector:aSelector withObject:sender];
return YES;
}
//
// Otherwise traverse the responder chain
//
return NO;
}
return NO; // Otherwise traverse
} // the responder chain
- targetForAction:(SEL)aSelector
{
return self;
}
- (BOOL)tryToPerform:(SEL)aSelector
with:anObject
- (BOOL)tryToPerform:(SEL)aSelector with:anObject
{
return NO;
}
// Setting the application's icon
- (void)setApplicationIconImage:(NSImage *)anImage
{
{ // Set the app's icon
if (app_icon != nil)
{
[app_icon release];
}
app_icon = [anImage retain];
}
@ -629,7 +568,6 @@ BOOL done = NO;
// notify that we will hide
[nc postNotificationName: NSApplicationWillHideNotification
object: self];
// TODO: hide the menu
// Tell the windows to hide
@ -637,7 +575,6 @@ BOOL done = NO;
[[window_list objectAtIndex:i] performHide:sender];
app_is_hidden = YES;
// notify that we did hide
[nc postNotificationName: NSApplicationDidHideNotification
object: self];
@ -651,30 +588,26 @@ BOOL done = NO;
- (void)unhide:sender
{
int i, count;
// Tell the windows to unhide
// Tell windows to unhide
for (i = 0, count = [window_list count]; i < count; i++)
[[window_list objectAtIndex:i] performUnhide:sender];
// TODO: unhide the menu
app_is_hidden = NO;
// Bring the key window to the front
[[self keyWindow] makeKeyAndOrderFront:self];
// Bring the key window to
[[self keyWindow] makeKeyAndOrderFront:self]; // the front
}
- (void)unhideWithoutActivation
{
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
// notify that we will unhide
// notify we will unhide
[nc postNotificationName: NSApplicationWillUnhideNotification
object: self];
[self unhide: self];
// notify that we did unhide
// notify we did unhide
[nc postNotificationName: NSApplicationDidUnhideNotification
object: self];
}
@ -691,8 +624,10 @@ BOOL done = NO;
for (i = 0;i < j; ++i)
{
w = [window_list objectAtIndex:i];
if ([w isKeyWindow]) return w;
if ([w isKeyWindow])
return w;
}
return nil;
}
@ -705,13 +640,14 @@ BOOL done = NO;
for (i = 0;i < j; ++i)
{
w = [window_list objectAtIndex:i];
if ([w isMainWindow]) return w;
if ([w isMainWindow])
return w;
}
return nil;
}
- (NSWindow *)makeWindowsPerform:(SEL)aSelector
inOrder:(BOOL)flag
- (NSWindow *)makeWindowsPerform:(SEL)aSelector inOrder:(BOOL)flag
{
return nil;
}
@ -733,21 +669,21 @@ BOOL done = NO;
windows_need_update = flag;
}
- (void)updateWindows // send an update message to
{ // all visible windows
- (void)updateWindows // send an update message
{ // to all visible windows
int i, count;
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
// notify that we will update
// notify that an update is
// imminent
[nc postNotificationName:NSApplicationWillUpdateNotification object:self];
for (i = 0, count = [window_list count]; i < count; i++)
{
NSWindow *win = [window_list objectAtIndex:i];
if([win isVisible]) // send update only if
if([win isVisible]) // send update only if the
[win update]; // window is visible
}
// notify that we did update
// notify update did occur
[nc postNotificationName:NSApplicationDidUpdateNotification object:self];
}
@ -765,8 +701,10 @@ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
for (i = 0;i < j; ++i)
{
w = [window_list objectAtIndex:i];
if ([w windowNumber] == windowNum) return w;
if ([w windowNumber] == windowNum)
return w;
}
return nil;
}
@ -803,24 +741,20 @@ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
NSMenuItem *mc;
NSArray *mi;
// Release old and retain new
[aMenu retain];
if(main_menu)
[aMenu retain]; // Release old menu and
if(main_menu) // retain new
[main_menu release];
main_menu = aMenu;
// Search for a menucell with the name Windows
// This is the default windows menu
mi = [main_menu itemArray];
j = [mi count];
windows_menu = nil;
for (i = 0;i < j; ++i)
mi = [main_menu itemArray]; // find a menucell with
j = [mi count]; // the title Windows
windows_menu = nil; // this is the default
for (i = 0;i < j; ++i) // windows menu
{
mc = [mi objectAtIndex:i];
if ([[mc stringValue] compare:@"Windows"] == NSOrderedSame)
{
// Found it!
windows_menu = mc;
windows_menu = mc; // Found it!
break;
}
}
@ -835,23 +769,18 @@ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
{
int i;
// Not a subclass of window --forget it
if (![aWindow isKindOfClass:[NSWindow class]])
return;
if (![aWindow isKindOfClass:[NSWindow class]]) // proceed only if subclass
return; // of window
// Add to our window list, the array retains it
i = [window_list count];
[window_list addObject:aWindow];
i = [window_list count]; // Add to our window list,
[window_list addObject:aWindow]; // the array retains it
// set its window number
[aWindow setWindowNumber:window_count];
[aWindow setWindowNumber:window_count]; // set its window number
++window_count;
// If this was the first window then
// make it the main and key window
if (i == 0)
{
[aWindow becomeMainWindow];
if (i == 0) // If this was the first
{ // window then make it the
[aWindow becomeMainWindow]; // main and key window
[aWindow becomeKeyWindow];
}
}
@ -868,8 +797,7 @@ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
- (void)removeWindowsItem:aWindow
{
// +++ This should be different
if (aWindow == key_window)
if (aWindow == key_window) // This should be different
key_window = nil;
if (aWindow == main_window)
main_window = nil;
@ -879,9 +807,8 @@ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
// and subsequently NSWindow is caling us to remove itself.
if (gnustep_gui_app_is_in_dealloc)
return;
// Remove it from the window list
[window_list removeObject: aWindow];
// Remove window from the
[window_list removeObject: aWindow]; // window list
return;
}
@ -925,15 +852,14 @@ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
return nil;
}
// Getting the display postscript context
- (NSDPSContext *)context
- (NSDPSContext *)context // return the DPS context
{
return [NSDPSContext currentContext];
}
// Reporting an exception
- (void)reportException:(NSException *)anException
{}
{
}
//
// Terminating the application
@ -944,8 +870,7 @@ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
app_should_quit = YES;
}
// Assigning a delegate
- delegate
- delegate // Assigning a delegate
{
return delegate;
}
@ -1135,30 +1060,17 @@ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
}
+ (NSEvent *)getNullEvent;
{
return gnustep_gui_null_event;
{ // return the class
return gnustep_gui_null_event; // dummy event
}
// Get next event
- (void)getNextEvent
{
[event_queue addObject:gnustep_gui_null_event];
}
- (NSEvent *)peekNextEvent
{
return gnustep_gui_null_event;
}
// handle a non-translated event
- (void)handleNullEvent
{}
- (void)_flushCommunicationChannels
{}
- (void)_nextEvent // get next event
{ // implemented in
} // backend
- (void)setupRunLoopInputSourcesForMode:(NSString*)mode
{}
{ // implemented in
} // backend
@end

View file

@ -45,12 +45,12 @@ float tabSize;
while(*str != '\0') // calc the additional size
{ // to be added for tabs.
if(*str++ == '\t')
{
i += j; // j is the max number of spaces
j = TABWIDTH; // needed per tab. this number
} // varies in order to align tabs
else // at even multiples of TABWIDTH+1.
j = j-- > 0 ? j : TABWIDTH;
{ // j is initialized to the
i += j; // max number of spaces
j = TABWIDTH; // needed per tab. it then
} // varies in order to align
else // tabs to even multiples
j = j-- > 0 ? j : TABWIDTH; // of TABWIDTH + 1.
};
// if font is not
if(!(font = [attrs objectForKey:NSFontAttributeName])) // specified, use

View file

@ -56,9 +56,7 @@ static NSString *timerKey = @"NSEventTimersKey";
if (self == [NSEvent class])
{
NSDebugLog(@"Initialize NSEvent class\n");
// Initial version
[self setVersion:1];
[self setVersion:1]; // Initial version
}
}
@ -239,10 +237,9 @@ NSEvent* periodicEvent = [self otherEventWithType:NSPeriodic
[theApp postEvent:periodicEvent atStart:NO]; // place a periodic
} // event in the queue
+ (void)_registerRealTimer:(NSTimer*)timer
{ // this method provides a
NSTimer* realTimer; // means of delaying the
// start of periodic events
+ (void)_registerRealTimer:(NSTimer*)timer // this method provides a
{ // means of delaying the
NSTimer* realTimer; // start of periodic events
NSMutableDictionary *dict = [[NSThread currentThread] threadDictionary];
NSDebugLog (@"_registerRealTimer:");
@ -253,7 +250,6 @@ NSEvent* periodicEvent = [self otherEventWithType:NSPeriodic
userInfo:nil
repeats:YES]; // Add the real timer to the timers
// dictionary and to the run loop
/* xxx what if there is already a timer - are we sure there isn't? */
[dict setObject: realTimer forKey: timerKey];
[[NSRunLoop currentRunLoop] addTimer: realTimer
forMode: NSEventTrackingRunLoopMode];
@ -265,9 +261,8 @@ NSEvent* periodicEvent = [self otherEventWithType:NSPeriodic
NSMutableDictionary *dict = [[NSThread currentThread] threadDictionary];
NSDebugLog (@"stopPeriodicEvents");
/* Remove any existing timer for this thread */
timer = [dict objectForKey: timerKey];
// Remove any existing
timer = [dict objectForKey: timerKey]; // timer for this thread
[timer invalidate];
[dict removeObjectForKey: timerKey];
}

View file

@ -223,7 +223,6 @@ NSPoint point;
_knobMoved = YES;
}
if (!_knobMoved) // button scrolling
{
if (scroller == _horizScroller)
@ -233,17 +232,12 @@ NSPoint point;
}
else
{
if (scroller == _vertScroller) // For the vertical
{ // scroller the amount
point.x = clipViewBounds.origin.x; // should be reversed
amount = -amount;
// If the view is flipped we also have to
// reverse the meanings of increasing or
// decreasing of the y coordinate
// if (![_contentView isFlipped])
// amount = -amount;
if (scroller == _vertScroller)
{
point.x = clipViewBounds.origin.x;
// If view is flipped
if ([_contentView isFlipped]) // reverse the scroll
amount = -amount; // direction
NSDebugLog (@"increment/decrement: amount = %f, flipped = %d",
amount, [_contentView isFlipped]);
point.y = clipViewBounds.origin.y + amount;
@ -253,8 +247,8 @@ NSPoint point;
return; // do nothing
}
}
else
{ // knob scolling
else // knob scolling
{
if (scroller == _horizScroller)
{
point.x = floatValue * (documentRect.size.width

View file

@ -458,9 +458,8 @@ static NSButtonCell* knobCell = nil;
_hitPart = [self testPart:location];
rect = [self rectForPart:_hitPart];
switch (_hitPart) {
// determine which cell was hit
switch (_hitPart) // determine which
{ // cell was hit
case NSScrollerIncrementLine:
case NSScrollerIncrementPage:
theCell = (_isHorizontal ? rightCell : upCell);
@ -476,15 +475,17 @@ static NSButtonCell* knobCell = nil;
break;
}
if (theCell) {
if (theCell)
{
[theCell highlight:YES withFrame:rect inView:self];
// [self setNeedsDisplayInRect:rect]; // not needed by XRAW
[window flushWindow];
NSLog (@"tracking cell %x", theCell);
// Track the mouse until mouse goes up
shouldReturn = [theCell trackMouse:theEvent
inRect:rect
ofView:self
shouldReturn = [theCell trackMouse:theEvent // Track the mouse
inRect:rect // until left mouse
ofView:self // goes up
untilMouseUp:YES];
if([_target isKindOf:[NSScrollView class]]) // a hack for XRAW
@ -492,6 +493,7 @@ static NSButtonCell* knobCell = nil;
if([[_target contentView] respondsTo:@selector(_freeMatrix)])
[[_target contentView] _freeMatrix];
}
[theCell highlight:NO withFrame:rect inView:self];
// [self setNeedsDisplayInRect:rect]; // not needed by XRAW
[window flushWindow];
@ -504,7 +506,8 @@ static NSButtonCell* knobCell = nil;
untilDate:[NSDate distantFuture]
inMode:NSEventTrackingRunLoopMode
dequeue:YES];
} while ([theEvent type] != NSLeftMouseUp);
}
while ([theEvent type] != NSLeftMouseUp);
NSDebugLog (@"return from trackScrollButtons");
}

View file

@ -851,21 +851,21 @@ int i, count;
NSView* subview = [sub_views objectAtIndex:i];
NSRect subviewFrame = subview->frame;
NSRect intersection;
// If the subview is rotated compute its
// bounding rectangle and use this one
// instead of the subview's frame.
// If the subview is rotated compute
// its bounding rectangle and use this
// one instead of the subview's frame.
if ([subview->frameMatrix isRotated])
[subview->frameMatrix boundingRectFor:subviewFrame
result:&subviewFrame];
// Determine if the subview's frame
// intersects "rect" so that we can display
// the subview.
// intersects "rect" so that we can
// display the subview.
intersection = NSIntersectionRect (rect, subviewFrame);
if (intersection.origin.x || intersection.origin.y ||
intersection.size.width || intersection.size.height)
{ // Convert the intersection rectangle to
// the subview's coordinates
{ // Convert the intersection rectangle
// to the subview's coordinates
intersection = [subview convertRect:intersection fromView:self];
[subview displayRect:intersection];
}