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:
Felipe A. Rodriguez 1998-11-02 17:42:23 +00:00
parent 5f7a30972f
commit dafd348e5d
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;
}
@ -125,19 +128,13 @@ extern NSString *NSEventTrackingRunLoopMode;
//
- (NSEvent *)currentEvent;
- (void)discardEventsMatchingMask:(unsigned int)mask
beforeEvent:(NSEvent *)lastEvent;
beforeEvent:(NSEvent *)lastEvent;
- (NSEvent *)nextEventMatchingMask:(unsigned int)mask
untilDate:(NSDate *)expiration
inMode:(NSString *)mode
dequeue:(BOOL)flag;
untilDate:(NSDate *)expiration
inMode:(NSString *)mode
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

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
{ // 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

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

View file

@ -223,27 +223,21 @@ NSPoint point;
_knobMoved = YES;
}
if (!_knobMoved) // button scrolling
{
if (scroller == _horizScroller)
if (scroller == _horizScroller)
{
point.x = clipViewBounds.origin.x + amount;
point.y = clipViewBounds.origin.y;
}
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,9 +247,9 @@ NSPoint point;
return; // do nothing
}
}
else
{ // knob scolling
if (scroller == _horizScroller)
else // knob scolling
{
if (scroller == _horizScroller)
{
point.x = floatValue * (documentRect.size.width
- clipViewBounds.size.width);

View file

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

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.
// Determine if the subview's frame
// 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];
}