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 // Attributes
NSMutableArray *window_list; NSMutableArray *window_list;
NSMutableArray *event_queue; NSMutableArray *event_queue;
NSMutableArray *recycled_event_queue;
NSEvent *current_event; NSEvent *current_event;
id key_window; id key_window;
id main_window; id main_window;
@ -78,6 +79,8 @@ extern NSString *NSEventTrackingRunLoopMode;
BOOL windows_need_update; BOOL windows_need_update;
NSImage *app_icon; NSImage *app_icon;
BOOL inTrackingLoop;
// Reserved for back-end use // Reserved for back-end use
void *be_app_reserved; void *be_app_reserved;
} }
@ -125,19 +128,13 @@ extern NSString *NSEventTrackingRunLoopMode;
// //
- (NSEvent *)currentEvent; - (NSEvent *)currentEvent;
- (void)discardEventsMatchingMask:(unsigned int)mask - (void)discardEventsMatchingMask:(unsigned int)mask
beforeEvent:(NSEvent *)lastEvent; beforeEvent:(NSEvent *)lastEvent;
- (NSEvent *)nextEventMatchingMask:(unsigned int)mask - (NSEvent *)nextEventMatchingMask:(unsigned int)mask
untilDate:(NSDate *)expiration untilDate:(NSDate *)expiration
inMode:(NSString *)mode inMode:(NSString *)mode
dequeue:(BOOL)flag; dequeue:(BOOL)flag;
- (void)postEvent:(NSEvent *)event atStart:(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 // Sending action messages
// //
@ -271,15 +268,10 @@ extern NSString *NSEventTrackingRunLoopMode;
+ (void)setNullEvent:(NSEvent *)e; + (void)setNullEvent:(NSEvent *)e;
+ (NSEvent *)getNullEvent; + (NSEvent *)getNullEvent;
// Get next event
- (void)getNextEvent;
- (NSEvent *)peekNextEvent;
// handle a non-translated event
- (void)handleNullEvent;
/* Private methods */ /* Private methods */
- (void)_flushCommunicationChannels;
// Get next event
- (void)_nextEvent;
@end @end

File diff suppressed because it is too large Load diff

View file

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

View file

@ -53,13 +53,11 @@ static NSString *timerKey = @"NSEventTimersKey";
// //
+ (void)initialize + (void)initialize
{ {
if (self == [NSEvent class]) if (self == [NSEvent class])
{ {
NSDebugLog(@"Initialize NSEvent class\n"); NSDebugLog(@"Initialize NSEvent class\n");
[self setVersion:1]; // Initial version
// Initial version }
[self setVersion:1];
}
} }
// //
@ -191,14 +189,14 @@ NSEvent *e = [[[NSEvent alloc] init] autorelease];
+ (void)startPeriodicEventsAfterDelay:(NSTimeInterval)delaySeconds + (void)startPeriodicEventsAfterDelay:(NSTimeInterval)delaySeconds
withPeriod:(NSTimeInterval)periodSeconds withPeriod:(NSTimeInterval)periodSeconds
{ {
NSTimer* timer; NSTimer* timer;
NSMutableDictionary *dict = [[NSThread currentThread] threadDictionary]; NSMutableDictionary *dict = [[NSThread currentThread] threadDictionary];
NSDebugLog (@"startPeriodicEventsAfterDelay:withPeriod:"); NSDebugLog (@"startPeriodicEventsAfterDelay:withPeriod:");
// Check this thread // Check this thread
if ([dict objectForKey: timerKey]) // for a pending timer if ([dict objectForKey: timerKey]) // for a pending timer
[NSException raise:NSInternalInconsistencyException [NSException raise:NSInternalInconsistencyException
format:@"Periodic events are already being generated for " format:@"Periodic events are already being generated for "
@"this thread %x", [NSThread currentThread]]; @"this thread %x", [NSThread currentThread]];
// If the delay time is 0 then register // If the delay time is 0 then register
// a timer immediately. Otherwise // a timer immediately. Otherwise
@ -216,9 +214,9 @@ NSEvent *e = [[[NSEvent alloc] init] autorelease];
userInfo:[NSNumber numberWithDouble:periodSeconds] userInfo:[NSNumber numberWithDouble:periodSeconds]
repeats:NO]; repeats:NO];
[[NSRunLoop currentRunLoop] addTimer: timer [[NSRunLoop currentRunLoop] addTimer: timer
forMode: NSEventTrackingRunLoopMode]; forMode: NSEventTrackingRunLoopMode];
[dict setObject: timer forKey: timerKey]; [dict setObject: timer forKey: timerKey];
} }
+ (void)_timerFired:(NSTimer*)timer + (void)_timerFired:(NSTimer*)timer
@ -239,37 +237,34 @@ NSEvent* periodicEvent = [self otherEventWithType:NSPeriodic
[theApp postEvent:periodicEvent atStart:NO]; // place a periodic [theApp postEvent:periodicEvent atStart:NO]; // place a periodic
} // event in the queue } // event in the queue
+ (void)_registerRealTimer:(NSTimer*)timer + (void)_registerRealTimer:(NSTimer*)timer // this method provides a
{ // this method provides a { // means of delaying the
NSTimer* realTimer; // means of delaying the NSTimer* realTimer; // start of periodic events
// start of periodic events NSMutableDictionary *dict = [[NSThread currentThread] threadDictionary];
NSMutableDictionary *dict = [[NSThread currentThread] threadDictionary];
NSDebugLog (@"_registerRealTimer:"); NSDebugLog (@"_registerRealTimer:");
realTimer = [NSTimer timerWithTimeInterval:[[timer userInfo] doubleValue] realTimer = [NSTimer timerWithTimeInterval:[[timer userInfo] doubleValue]
target:self target:self
selector:@selector(_timerFired:) selector:@selector(_timerFired:)
userInfo:nil userInfo:nil
repeats:YES]; // Add the real timer to the timers repeats:YES]; // Add the real timer to the timers
// dictionary and to the run loop // 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];
[dict setObject: realTimer forKey: timerKey]; [[NSRunLoop currentRunLoop] addTimer: realTimer
[[NSRunLoop currentRunLoop] addTimer: realTimer forMode: NSEventTrackingRunLoopMode];
forMode: NSEventTrackingRunLoopMode];
} }
+ (void)stopPeriodicEvents + (void)stopPeriodicEvents
{ {
NSTimer* timer; NSTimer* timer;
NSMutableDictionary *dict = [[NSThread currentThread] threadDictionary]; NSMutableDictionary *dict = [[NSThread currentThread] threadDictionary];
NSDebugLog (@"stopPeriodicEvents"); NSDebugLog (@"stopPeriodicEvents");
// Remove any existing
/* Remove any existing timer for this thread */ timer = [dict objectForKey: timerKey]; // timer for this thread
timer = [dict objectForKey: timerKey]; [timer invalidate];
[timer invalidate]; [dict removeObjectForKey: timerKey];
[dict removeObjectForKey: timerKey];
} }
// //
@ -277,13 +272,13 @@ NSEvent* periodicEvent = [self otherEventWithType:NSPeriodic
// //
- (void)dealloc - (void)dealloc
{ {
if ((event_type == NSKeyUp) || (event_type == NSKeyDown)) if ((event_type == NSKeyUp) || (event_type == NSKeyDown))
{ {
[event_data.key.char_keys release]; [event_data.key.char_keys release];
[event_data.key.unmodified_keys release]; [event_data.key.unmodified_keys release];
} }
[super dealloc]; [super dealloc];
} }
// //
@ -291,37 +286,37 @@ NSEvent* periodicEvent = [self otherEventWithType:NSPeriodic
// //
- (NSDPSContext *)context - (NSDPSContext *)context
{ {
return event_context; return event_context;
} }
- (NSPoint)locationInWindow - (NSPoint)locationInWindow
{ {
return location_point; return location_point;
} }
- (unsigned int)modifierFlags - (unsigned int)modifierFlags
{ {
return modifier_flags; return modifier_flags;
} }
- (NSTimeInterval)timestamp - (NSTimeInterval)timestamp
{ {
return event_time; return event_time;
} }
- (NSEventType)type - (NSEventType)type
{ {
return event_type; return event_type;
} }
- (NSWindow *)window - (NSWindow *)window
{ {
return [NSWindow windowWithNumber:window_num]; return [NSWindow windowWithNumber:window_num];
} }
- (int)windowNumber - (int)windowNumber
{ {
return window_num; return window_num;
} }
// //
@ -329,34 +324,34 @@ NSEvent* periodicEvent = [self otherEventWithType:NSPeriodic
// //
- (NSString *)characters - (NSString *)characters
{ {
if ((event_type != NSKeyUp) && (event_type != NSKeyDown)) if ((event_type != NSKeyUp) && (event_type != NSKeyDown))
return nil; return nil;
return event_data.key.char_keys; return event_data.key.char_keys;
} }
- (NSString *)charactersIgnoringModifiers - (NSString *)charactersIgnoringModifiers
{ {
if ((event_type != NSKeyUp) && (event_type != NSKeyDown)) if ((event_type != NSKeyUp) && (event_type != NSKeyDown))
return nil; return nil;
return event_data.key.unmodified_keys; return event_data.key.unmodified_keys;
} }
- (BOOL)isARepeat - (BOOL)isARepeat
{ {
if ((event_type != NSKeyUp) && (event_type != NSKeyDown)) if ((event_type != NSKeyUp) && (event_type != NSKeyDown))
return NO; return NO;
return event_data.key.repeat; return event_data.key.repeat;
} }
- (unsigned short)keyCode - (unsigned short)keyCode
{ {
if ((event_type != NSKeyUp) && (event_type != NSKeyDown)) if ((event_type != NSKeyUp) && (event_type != NSKeyDown))
return 0; return 0;
return event_data.key.key_code; return event_data.key.key_code;
} }
// //

View file

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

View file

@ -444,69 +444,72 @@ static NSButtonCell* knobCell = nil;
- (void)trackScrollButtons:(NSEvent*)theEvent - (void)trackScrollButtons:(NSEvent*)theEvent
{ {
NSApplication *theApp = [NSApplication sharedApplication]; NSApplication *theApp = [NSApplication sharedApplication];
unsigned int eventMask = NSLeftMouseDownMask | NSLeftMouseUpMask | unsigned int eventMask = NSLeftMouseDownMask | NSLeftMouseUpMask |
NSLeftMouseDraggedMask | NSMouseMovedMask; NSLeftMouseDraggedMask | NSMouseMovedMask;
NSPoint location; NSPoint location;
BOOL shouldReturn = NO; BOOL shouldReturn = NO;
id theCell = nil; id theCell = nil;
NSRect rect; NSRect rect;
NSDebugLog (@"trackScrollButtons"); NSDebugLog (@"trackScrollButtons");
do { do {
location = [self convertPoint:[theEvent locationInWindow]fromView:nil]; location = [self convertPoint:[theEvent locationInWindow]fromView:nil];
_hitPart = [self testPart:location]; _hitPart = [self testPart:location];
rect = [self rectForPart:_hitPart]; rect = [self rectForPart:_hitPart];
switch (_hitPart) // determine which
{ // cell was hit
case NSScrollerIncrementLine:
case NSScrollerIncrementPage:
theCell = (_isHorizontal ? rightCell : upCell);
break;
switch (_hitPart) { case NSScrollerDecrementLine:
// determine which cell was hit case NSScrollerDecrementPage:
theCell = (_isHorizontal ? leftCell : downCell);
break;
case NSScrollerIncrementLine: default:
case NSScrollerIncrementPage: theCell = nil;
theCell = (_isHorizontal ? rightCell : upCell); break;
break; }
case NSScrollerDecrementLine: if (theCell)
case NSScrollerDecrementPage: {
theCell = (_isHorizontal ? leftCell : downCell); [theCell highlight:YES withFrame:rect inView:self];
break; // [self setNeedsDisplayInRect:rect]; // not needed by XRAW
[window flushWindow];
default: NSLog (@"tracking cell %x", theCell);
theCell = nil;
break; shouldReturn = [theCell trackMouse:theEvent // Track the mouse
} inRect:rect // until left mouse
ofView:self // goes up
untilMouseUp:YES];
if (theCell) { if([_target isKindOf:[NSScrollView class]]) // a hack for XRAW
[theCell highlight:YES withFrame:rect inView:self]; { // FIX ME
// [self setNeedsDisplayInRect:rect]; // not needed by XRAW if([[_target contentView] respondsTo:@selector(_freeMatrix)])
[window flushWindow]; [[_target contentView] _freeMatrix];
NSLog (@"tracking cell %x", theCell); }
// Track the mouse until mouse goes up
shouldReturn = [theCell trackMouse:theEvent
inRect:rect
ofView:self
untilMouseUp:YES];
if([_target isKindOf:[NSScrollView class]]) // a hack for XRAW [theCell highlight:NO withFrame:rect inView:self];
{ // FIX ME // [self setNeedsDisplayInRect:rect]; // not needed by XRAW
if([[_target contentView] respondsTo:@selector(_freeMatrix)]) [window flushWindow];
[[_target contentView] _freeMatrix]; }
}
[theCell highlight:NO withFrame:rect inView:self];
// [self setNeedsDisplayInRect:rect]; // not needed by XRAW
[window flushWindow];
}
if (shouldReturn) if (shouldReturn)
break; break;
theEvent = [theApp nextEventMatchingMask:eventMask theEvent = [theApp nextEventMatchingMask:eventMask
untilDate:[NSDate distantFuture] untilDate:[NSDate distantFuture]
inMode:NSEventTrackingRunLoopMode inMode:NSEventTrackingRunLoopMode
dequeue:YES]; dequeue:YES];
} while ([theEvent type] != NSLeftMouseUp); }
while ([theEvent type] != NSLeftMouseUp);
NSDebugLog (@"return from trackScrollButtons"); NSDebugLog (@"return from trackScrollButtons");
} }
- (BOOL)sendActionO:(SEL)theAction to:(id)theTarget - (BOOL)sendActionO:(SEL)theAction to:(id)theTarget

View file

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