Run loop integrated. Configure detects libFoundation.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@2280 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
netcrep 1997-04-22 18:23:58 +00:00
parent 12cb8088c1
commit f38b177296
27 changed files with 2770 additions and 1535 deletions

View file

@ -53,7 +53,6 @@ ALL_CFLAGS = $(ALL_CPPFLAGS) $(CFLAGS)
DEFS = -DGNUSTEP_INSTALL_LIBDIR=\"$(gnustep_libdir)\" @DEFS@
GCC_LIB =
OBJC_LIB = -lobjc
SYS_LIBS =
ADD_LIBS = @LIBS@
@ -236,14 +235,14 @@ OBJS = $(OBJS_WITHOUT_INIT)
.SUFFIXES: .m
.m$(oext):
$(CC) -c $(ALL_CFLAGS) $(DEFS) -o $@ $<
$(CC) @OBJC_RUNTIME_FLAG@ -c $(ALL_CFLAGS) $(DEFS) -o $@ $<
.c$(oext):
$(CC) -c $(ALL_CFLAGS) $(DEFS) -o $@ $<
#
# libraries
#
LIBS = $(GCC_LIB) $(OBJC_LIB) $(SYS_LIBS) $(ADD_LIBS)
LIBS = $(GCC_LIB) $(SYS_LIBS) $(ADD_LIBS)
#
# targets

View file

@ -219,6 +219,17 @@
return tag;
}
- (id)copyWithZone:(NSZone*)zone
{
NSActionCell* c = [super copyWithZone:zone];
[c setTag:tag];
[c setTarget:target];
[c setAction:action];
return c;
}
//
// NSCoding protocol
//

View file

@ -30,6 +30,7 @@
#include <Foundation/NSArray.h>
#include <Foundation/NSNotification.h>
#include <Foundation/NSRunLoop.h>
#include <DPSClient/NSDPSContext.h>
#include <AppKit/NSApplication.h>
#include <AppKit/NSPopUpButton.h>
@ -172,6 +173,12 @@ NSString *NSApplicationWillUpdateNotification = @"ApplicationWillUpdate";
//
[self setNextResponder:NULL];
/* Set up the run loop object for the current thread */
[self setupRunLoopInputSourcesForMode:NSDefaultRunLoopMode];
[self setupRunLoopInputSourcesForMode:NSConnectionReplyMode];
[self setupRunLoopInputSourcesForMode:NSModalPanelRunLoopMode];
[self setupRunLoopInputSourcesForMode:NSEventTrackingRunLoopMode];
return self;
}
@ -267,9 +274,10 @@ NSString *NSApplicationWillUpdateNotification = @"ApplicationWillUpdate";
do
{
e = [self nextEventMatchingMask:NSAnyEventMask untilDate:nil
inMode:nil dequeue:YES];
if (e != gnustep_gui_null_event)
e = [self nextEventMatchingMask:NSAnyEventMask
untilDate:[NSDate distantFuture]
inMode:NSDefaultRunLoopMode dequeue:YES];
if (e)
[self sendEvent: e];
else
{
@ -447,14 +455,16 @@ NSString *NSApplicationWillUpdateNotification = @"ApplicationWillUpdate";
if ([event_queue count])
{
j = [event_queue count];
for (i = j-1;i >= 0; --i)
// for (i = j-1;i >= 0; --i)
for (i = 0; i < j; i++)
{
e = [event_queue objectAtIndex: i];
if ([self event: e matchMask: mask])
{
[e retain];
[event_queue removeObjectAtIndex: i];
[self setCurrentEvent: e];
return e;
return [e autorelease];
}
}
}
@ -463,18 +473,39 @@ NSString *NSApplicationWillUpdateNotification = @"ApplicationWillUpdate";
done = NO;
while (!done)
{
e = [self getNextEvent];
#if USE_RUN_LOOP
NSRunLoop* currentLoop = [NSRunLoop currentRunLoop];
NSDate* limitDate = [currentLoop limitDateForMode:mode];
// Check mask
if ([self event: e matchMask: mask])
{
if (e)
{
[event_queue removeObject: e];
}
done = YES;
if (!expiration)
expiration = [NSDate distantFuture];
if (limitDate)
limitDate = [expiration earlierDate:limitDate];
else
limitDate = expiration;
// NSLog (@"calling runMode:beforeDate:");
[currentLoop runMode:mode beforeDate:limitDate];
// NSLog (@"return from runMode:beforeDate:");
#else
e = [self getNextEvent];
#endif
if ([event_queue count]) {
e = [[event_queue lastObject] retain];
// Check mask
if ([self event: e matchMask: mask])
{
if (e)
{
[event_queue removeObject: e];
}
done = YES;
}
}
}
}
// Unhide the cursor if necessary
// but only if its not a null event
@ -495,7 +526,7 @@ NSString *NSApplicationWillUpdateNotification = @"ApplicationWillUpdate";
}
[self setCurrentEvent: e];
return e;
return [e autorelease];
}
- (NSEvent *)peekEventMatchingMask:(unsigned int)mask
@ -1129,4 +1160,7 @@ NSString *NSApplicationWillUpdateNotification = @"ApplicationWillUpdate";
- (void)handleNullEvent
{}
- (void)setupRunLoopInputSourcesForMode:(NSString*)mode
{}
@end

View file

@ -293,7 +293,7 @@ id gnustep_gui_nsbutton_class = nil;
return;
// capture mouse
[[self window] captureMouse: self];
// [[self window] captureMouse: self];
[self lockFocus];
done = NO;
@ -311,12 +311,12 @@ id gnustep_gui_nsbutton_class = nil;
{
NSDebugLog(@"NSButton process another event\n");
e = [theApp nextEventMatchingMask:event_mask untilDate:nil
inMode:nil dequeue:YES];
inMode:NSEventTrackingRunLoopMode dequeue:YES];
}
}
// Release mouse
[[self window] releaseMouse: self];
// [[self window] releaseMouse: self];
// If the mouse went up in the button
if (mouseUp)

View file

@ -319,11 +319,6 @@
control_view = controlView;
}
+ (BOOL)prefersTrackingUntilMouseUp
{
return YES;
}
//
// Simulating a Click
//
@ -331,6 +326,22 @@
{
}
- (id)copyWithZone:(NSZone*)zone
{
NSButtonCell* c = [super copyWithZone:zone];
[c setAlternateTitle:altContents];
[c setAlternateImage:altImage];
[c setKeyEquivalent:keyEquivalent];
[c setKeyEquivalentFont:keyEquivalentFont];
[c setKeyEquivalentModifierMask:keyEquivalentModifierMask];
[c setTransparent:transparent];
c->highlightsByMask = highlightsByMask;
c->showAltStateMask = showAltStateMask;
return c;
}
//
// NSCoding protocol
//

View file

@ -64,9 +64,8 @@
//
// Initializing an NSCell
//
- init
- _init
{
[super init];
cell_type = NSNullCellType;
cell_image = nil;
cell_font = nil;
@ -86,9 +85,16 @@
return self;
}
- init
{
self = [super init];
[self _init];
return self;
}
- (id)initImageCell:(NSImage *)anImage
{
[super init];
[self _init];
// Not an image class --then forget it
if (![anImage isKindOfClass:[NSImage class]])
@ -98,24 +104,12 @@
cell_image = [anImage retain];
image_position = NSImageOnly;
cell_font = [[NSFont userFontOfSize:16] retain];
cell_state = NO;
cell_highlighted = NO;
cell_enabled = YES;
cell_editable = NO;
cell_bordered = NO;
cell_bezeled = NO;
cell_scrollable = NO;
cell_selectable = NO;
cell_continuous = NO;
cell_float_autorange = NO;
cell_float_left = 0;
cell_float_right = 0;
return self;
}
- (id)initTextCell:(NSString *)aString
{
[super init];
[self _init];
// Not a string class --then forget it
//if (![aString isKindOfClass:[NSString class]])
@ -127,15 +121,6 @@
text_align = NSCenterTextAlignment;
cell_image = nil;
image_position = NSNoImage;
cell_state = NO;
cell_highlighted = NO;
cell_enabled = YES;
cell_editable = NO;
cell_bordered = NO;
cell_bezeled = NO;
cell_scrollable = NO;
cell_selectable = NO;
cell_continuous = NO;
cell_float_autorange = YES;
cell_float_left = 0;
cell_float_right = 6;
@ -649,7 +634,7 @@
{
last_point = point;
e = [theApp nextEventMatchingMask:event_mask untilDate:nil
inMode:nil dequeue:YES];
inMode:NSEventTrackingRunLoopMode dequeue:YES];
location = [e locationInWindow];
point = [controlView convertPoint: location fromView: nil];
NSDebugLog(@"NSCell location %f %f\n", location.x, location.y);
@ -751,6 +736,36 @@
- (void)setRepresentedObject:(id)anObject
{}
- (id)copyWithZone:(NSZone*)zone
{
NSCell* c = NSAllocateObject (isa, 0, zone);
[c setStringValue:contents];
[c setImage:cell_image];
[c setFont:cell_font];
[c setState:cell_state];
c->cell_highlighted = cell_highlighted;
[c setEnabled:cell_enabled];
[c setEditable:cell_editable];
[c setBordered:cell_bordered];
[c setBezeled:cell_bezeled];
[c setScrollable:cell_scrollable];
[c setSelectable:cell_selectable];
[c setContinuous:cell_continuous];
[c setFloatingPointFormat:cell_float_autorange
left:cell_float_left
right:cell_float_right];
c->image_position = image_position;
[c setType:cell_type];
[c setAlignment:text_align];
[c setEntryType:entry_type];
c->control_view = control_view;
c->cell_size = cell_size;
c->represented_object = [represented_object retain];
return c;
}
//
// NSCoding protocol
//

View file

@ -6,6 +6,7 @@
Copyright (C) 1996 Free Software Foundation, Inc.
Author: Scott Christley <scottc@net-community.com>
Author: Ovidiu Predescu <ovidiu@net-community.com>
Date: 1996
This file is part of the GNUstep GUI Library.
@ -26,11 +27,23 @@
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <Foundation/NSDictionary.h>
#include <Foundation/NSLock.h>
#include <Foundation/NSTimer.h>
#include <Foundation/NSRunLoop.h>
#include <Foundation/NSThread.h>
#include <Foundation/NSValue.h>
#include <Foundation/NSException.h>
#include <AppKit/NSEvent.h>
#include <AppKit/NSApplication.h>
@implementation NSEvent
// Class variables
static NSMutableDictionary* timers = nil;
static NSRecursiveLock* timersLock = nil;
//
// Private methods
//
@ -142,6 +155,8 @@
// Initial version
[self setVersion:1];
timers = [NSMutableDictionary new];
timersLock = [NSRecursiveLock new];
}
}
@ -287,10 +302,95 @@
//
+ (void)startPeriodicEventsAfterDelay:(NSTimeInterval)delaySeconds
withPeriod:(NSTimeInterval)periodSeconds
{}
{
NSTimer* timer;
NSThread* currentThread = [NSThread currentThread];
[timersLock lock];
NSDebugLog (@"startPeriodicEventsAfterDelay:withPeriod:");
/* Check for any pending timer for this thread */
if ([timers objectForKey:currentThread])
[NSException raise:NSInternalInconsistencyException
format:@"Periodic events are already being generated for "
@"this thread %x", currentThread];
/* If the delay time is 0 then register a timer right now. Otherwise register
a timer with no repeat that when fired registers the real timer */
if (!delaySeconds)
timer = [NSTimer timerWithTimeInterval:periodSeconds
target:self
selector:@selector(_timerFired:)
userInfo:nil
repeats:YES];
else
timer = [NSTimer timerWithTimeInterval:delaySeconds
target:self
selector:@selector(_registerRealTimer:)
userInfo:[NSNumber numberWithDouble:periodSeconds]
repeats:NO];
[[NSRunLoop currentRunLoop]
addTimer:timer forMode:NSEventTrackingRunLoopMode];
[timers setObject:timer forKey:currentThread];
[timersLock unlock];
}
+ (void)_timerFired:(NSTimer*)timer
{
NSEvent* periodicEvent
= [self otherEventWithType:NSPeriodic
location:NSZeroPoint
modifierFlags:0
timestamp:[[NSDate date] timeIntervalSinceReferenceDate]
windowNumber:0
context:[NSApp context]
subtype:0
data1:0
data2:0];
NSDebugLog (@"_timerFired:");
[NSApp postEvent:periodicEvent atStart:NO];
}
+ (void)_registerRealTimer:(NSTimer*)timer
{
NSTimeInterval periodSeconds = [[timer userInfo] doubleValue];
NSTimer* realTimer = [NSTimer timerWithTimeInterval:periodSeconds
target:self
selector:@selector(_timerFired:)
userInfo:nil
repeats:YES];
NSThread* currentThread = [NSThread currentThread];
NSDebugLog (@"_registerRealTimer:");
[timersLock lock];
/* Add the real timer into the timers dictionary and to the run loop */
[timers setObject:realTimer forKey:currentThread];
[[NSRunLoop currentRunLoop]
addTimer:realTimer forMode:NSEventTrackingRunLoopMode];
[timersLock unlock];
}
+ (void)stopPeriodicEvents
{}
{
NSTimer* timer;
NSThread* currentThread;
NSDebugLog (@"stopPeriodicEvents");
[timersLock lock];
currentThread = [NSThread currentThread];
/* Remove any existing timer for this thread */
timer = [timers objectForKey:currentThread];
[timer invalidate];
[timers removeObjectForKey:currentThread];
[timersLock unlock];
}
//
// Instance methods

View file

@ -5,7 +5,7 @@
Copyright (C) 1996 Free Software Foundation, Inc.
Author: Ovidiu Predescu <ovidiu@bx.logicnet.ro>
Author: Ovidiu Predescu <ovidiu@net-community.com>
Date: February 1997
A completely rewritten version of the original source by Scott Christley.

View file

@ -1,12 +1,12 @@
/*
/*
NSForm.m
Form class, a text field with a label
Copyright (C) 1996 Free Software Foundation, Inc.
Author: Scott Christley <scottc@net-community.com>
Date: 1996
Author: Ovidiu Predescu <ovidiu@net-community.com>
Date: March 1997
This file is part of the GNUstep GUI Library.
@ -27,103 +27,145 @@
*/
#include <AppKit/NSForm.h>
#include <AppKit/NSFormCell.h>
@implementation NSForm
//
// Laying Out the Form
//
- (NSFormCell *)addEntry:(NSString *)title
- (NSFormCell*)addEntry:(NSString*)title
{
return nil;
return [self insertEntry:title atIndex:[self numberOfRows]];
}
- (NSFormCell *)insertEntry:(NSString *)title
- (NSFormCell*)insertEntry:(NSString*)title
atIndex:(int)index
{
return nil;
[self insertRow:index];
return [self cellAtRow:index column:0];
}
- (void)removeEntryAtIndex:(int)index
{}
{
[self removeRow:index];
}
- (void)setBezeled:(BOOL)flag
{
int i, count = [self numberOfRows];
/* Set the bezeled attribute to the cell prototype */
[[self prototype] setBezeled:flag];
for (i = 0; i < count; i++)
[[self cellAtRow:i column:0] setBezeled:flag];
}
- (void)setBordered:(BOOL)flag
{
int i, count = [self numberOfRows];
/* Set the bordered attribute to the cell prototype */
[[self prototype] setBordered:flag];
for (i = 0; i < count; i++)
[[self cellAtRow:i column:0] setBordered:flag];
}
- (void)setEntryWidth:(float)width
{
NSSize size = [self cellSize];
size.width = width;
[self setCellSize:size];
}
- (void)setInterlineSpacing:(float)spacing
{}
{
[self setIntercellSpacing:NSMakeSize(0, spacing)];
}
/* For the title attributes we use the corresponding attributes from the cell.
For the text attributes we use instead the attributes inherited from the
NSCell class. */
- (void)setTitleAlignment:(NSTextAlignment)aMode
{
int i, count = [self numberOfRows];
/* Set the title alignment attribute to the cell prototype */
[[self prototype] setTitleAlignment:aMode];
for (i = 0; i < count; i++)
[[self cellAtRow:i column:0] setTitleAlignment:aMode];
}
- (void)setTextAlignment:(int)aMode
{
int i, count = [self numberOfRows];
/* Set the text alignment attribute to the cell prototype */
[[self prototype] setAlignment:aMode];
for (i = 0; i < count; i++)
[[self cellAtRow:i column:0] setAlignment:aMode];
}
- (void)setTitleFont:(NSFont*)fontObject
{
int i, count = [self numberOfRows];
/* Set the title font attribute to the cell prototype */
[[self prototype] setTitleFont:fontObject];
for (i = 0; i < count; i++)
[[self cellAtRow:i column:0] setTitleFont:fontObject];
}
- (void)setTextFont:(NSFont*)fontObject
{
int i, count = [self numberOfRows];
/* Set the text font attribute to the cell prototype */
[[self prototype] setFont:fontObject];
for (i = 0; i < count; i++)
[[self cellAtRow:i column:0] setFont:fontObject];
}
//
// Finding Indices
//
- (int)indexOfCellWithTag:(int)aTag
{
return 0;
int i, count = [self numberOfRows];
for (i = 0; i < count; i++)
if ([[self cellAtRow:i column:0] tag] == aTag)
return i;
return -1;
}
- (int)indexOfSelectedItem
{
return 0;
return [self selectedRow];
}
//
// Modifying Graphic Attributes
//
- (void)setBezeled:(BOOL)flag
{}
- (void)setBordered:(BOOL)flag
{}
- (void)setTextAlignment:(int)mode
{}
- (void)setTextFont:(NSFont *)fontObject
{}
- (void)setTitleAlignment:(NSTextAlignment)mode
{}
- (void)setTitleFont:(NSFont *)fontObject
{}
//
// Setting the Cell Class
//
+ (Class)cellClass
{
return nil;
}
+ (void)setCellClass:(Class)classId
{}
//
// Getting a Cell
//
- (id)cellAtIndex:(int)index
{
return nil;
return [self cellAtRow:index column:0];
}
//
// Displaying a Cell
//
- (void)drawCellAtIndex:(int)index
{}
{
id theCell = [self cellAtIndex:index];
[theCell drawWithFrame:[self cellFrameAtRow:index column:0]
inView:self];
}
- (void)drawCellAtRow:(int)row column:(int)column
{
[self drawCellAtIndex:row];
}
//
// Editing Text
//
- (void)selectTextAtIndex:(int)index
{}
//
// Resizing the Form
//
- (void)setEntryWidth:(float)width
{}
//
// NSCoding protocol
//
- (void)encodeWithCoder:aCoder
{
[super encodeWithCoder:aCoder];

View file

@ -5,8 +5,8 @@
Copyright (C) 1996 Free Software Foundation, Inc.
Author: Scott Christley <scottc@net-community.com>
Date: 1996
Author: Ovidiu Predescu <ovidiu@net-community.com>
Date: March 1997
This file is part of the GNUstep GUI Library.
@ -27,83 +27,101 @@
*/
#include <AppKit/NSFormCell.h>
#include <AppKit/NSFont.h>
#include <AppKit/NSTextFieldCell.h>
@implementation NSFormCell
//
// Initializing an NSFormCell
//
- (id)initTextCell:(NSString *)aString
/* The title attributes are those inherited from the NSActionCell class. */
- init
{
return nil;
self = [super init];
[self setBordered:NO];
[self setBezeled:NO];
titleWidth = -1;
textCell = [NSTextFieldCell new];
[textCell setBordered:YES];
[textCell setBezeled:YES];
return self;
}
//
// Determining an NSFormCell's Size
//
- (NSSize)cellSizeForBounds:(NSRect)aRect
- (void)dealloc
{
return NSZeroSize;
[textCell release];
[super dealloc];
}
//
// Determining Graphic Attributes
//
- (BOOL)isOpaque
{
return NO;
return [super isOpaque] && [textCell isOpaque];
}
//
// Modifying the Title
//
- (void)setTitle:(NSString *)aString
{}
- (void)setTitle:(NSString*)aString
{
[self setStringValue:aString];
}
- (void)setTitleAlignment:(NSTextAlignment)mode
{}
{
[self setAlignment:mode];
}
- (void)setTitleFont:(NSFont *)fontObject
{}
- (void)setTitleFont:(NSFont*)fontObject
{
[self setFont:fontObject];
}
- (void)setTitleWidth:(float)width
{}
- (NSString *)title
{
return nil;
titleWidth = width;
}
- (NSString*)title
{
return [self stringValue];
}
- (NSTextAlignment)titleAlignment
{
return 0;
return [self alignment];
}
- (NSFont *)titleFont
- (NSFont*)titleFont
{
return nil;
return [self font];
}
- (float)titleWidth
{
return 0;
if (titleWidth < 0)
return [[self font] widthOfString:[self title]];
else
return titleWidth;
}
- (float)titleWidth:(NSSize)aSize
- (float)titleWidth:(NSSize)size
{
// TODO
return 0;
}
//
// Displaying
//
- (void)drawInteriorWithFrame:(NSRect)cellFrame
inView:(NSView *)controlView
{}
inView:(NSView*)controlView
{
NSRect titleRect = cellFrame;
NSRect textRect;
titleRect.size.width = [self titleWidth] + 4;
[super drawInteriorWithFrame:titleRect inView:controlView];
textRect.origin.x = cellFrame.origin.x + titleRect.size.width;
textRect.origin.y = cellFrame.origin.y;
textRect.size.width = cellFrame.size.width - titleRect.size.width;
textRect.size.height = cellFrame.size.height;
[textCell drawInteriorWithFrame:textRect inView:controlView];
}
//
// NSCoding protocol
//
- (void)encodeWithCoder:aCoder
{
[super encodeWithCoder:aCoder];

File diff suppressed because it is too large Load diff

View file

@ -288,7 +288,7 @@ id gnustep_gui_nsscroller_class = nil;
{
last_point = point;
e = [theApp nextEventMatchingMask:event_mask untilDate:nil
inMode:nil dequeue:YES];
inMode:NSEventTrackingRunLoopMode dequeue:YES];
point = [self convertPoint: [e locationInWindow] fromView: nil];
if (is_horizontal)
@ -383,7 +383,7 @@ id gnustep_gui_nsscroller_class = nil;
{
last_point = point;
e = [theApp nextEventMatchingMask:event_mask untilDate:nil
inMode:nil dequeue:YES];
inMode:NSEventTrackingRunLoopMode dequeue:YES];
point = [self convertPoint: [e locationInWindow] fromView: nil];

View file

@ -936,7 +936,7 @@ NSString *NSWindowWillMoveNotification = @"WindowWillMove";
{
NSApplication *theApp = [NSApplication sharedApplication];
return [theApp nextEventMatchingMask: mask untilDate: nil
inMode: @"" dequeue: YES];
inMode:NSEventTrackingRunLoopMode dequeue: YES];
}
- (NSEvent *)nextEventMatchingMask:(unsigned int)mask