* NSWindow.h change window style enum to match WindowMaker's definition.

* GNUAlertPanel.m NSGetAlertPanel() replace centering code with call to
	center method, change window style mask, add class initialize.
	* libgnustep-gui.m rename to Functions.m.
	* Functions.m add new file as location for generic NS* and GS* functions,
	move backend NSEventMaskFromType() into it.
	* NSApplication.m discardEventsMatchingMask:.. rewrite (fix bugs),
	runModalSession: dump all events not for modal window (fixes modal panel
	button display bug), arrangeInFront: preliminary implemenation.
	* NSCell.m: Polish.
	* NSWindow.m: center remove display invocation per 4.2 docs.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@3426 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Felipe A. Rodriguez 1998-12-10 18:07:24 +00:00
parent caab58e8db
commit 134a561e0c
8 changed files with 225 additions and 219 deletions

View file

@ -1,3 +1,17 @@
Thu Dec 10 1998 Felipe A. Rodriguez <far@ix.netcom.com>
* NSWindow.h change window style enum to match WindowMaker's definition.
* GNUAlertPanel.m NSGetAlertPanel() replace centering code with call to
center method, change window style mask, add class initialize.
* libgnustep-gui.m rename to Functions.m.
* Functions.m add new file as location for generic NS* and GS* functions,
move backend NSEventMaskFromType() into it.
* NSApplication.m discardEventsMatchingMask:.. rewrite (fix bugs),
runModalSession: dump all events not for modal window (fixes modal panel
button display bug), arrangeInFront: preliminary implemenation.
* NSCell.m: Polish.
* NSWindow.m: center remove display invocation per 4.2 docs.
Wed Dec 9 1998 Felipe A. Rodriguez <far@ix.netcom.com>
* NSView.m resizeWithOldSuperviewSize: revert to previous code and add bug

View file

@ -54,19 +54,19 @@
@class NSScreen;
enum {
NSNormalWindowLevel = 0,
NSFloatingWindowLevel = 3,
NSDockWindowLevel = 5,
NSSubmenuWindowLevel = 10,
NSMainMenuWindowLevel = 20
NSNormalWindowLevel = 0,
NSFloatingWindowLevel = 3,
NSDockWindowLevel = 5,
NSSubmenuWindowLevel = 10,
NSMainMenuWindowLevel = 20
};
enum {
NSBorderlessWindowMask = 1,
NSTitledWindowMask = 2,
NSClosableWindowMask = 4,
NSMiniaturizableWindowMask = 8,
NSResizableWindowMask = 16
NSBorderlessWindowMask = 0,
NSTitledWindowMask = 1,
NSClosableWindowMask = 2,
NSMiniaturizableWindowMask = 4,
NSResizableWindowMask = 8
};
extern NSSize NSIconSize;

View file

@ -69,6 +69,16 @@ static GNUAlertPanel *reusableAlertPanel = nil;
@end
@implementation GNUAlertPanel
//
// Class methods
//
+ (void)initialize
{
if (self == [GNUAlertPanel class])
[self setVersion:1];
}
- (void) buttonAction: (id)sender
{
if (active == NO)
@ -129,7 +139,7 @@ static GNUAlertPanel *reusableAlertPanel = nil;
if (self)
{
NSView *content;
unsigned bs = 8.0; /* Inter-button space */
unsigned bs = 10.0; /* Inter-button space */
unsigned bh = 24.0; /* Button height. */
unsigned bw = 72.0; /* Button width. */
NSRect rect;
@ -373,25 +383,15 @@ NSGetAlertPanel(NSString *title,
return nil;
}
#else
NSRect frame = [[NSScreen mainScreen] frame];
/*
* Center the panel in the screen.
*/
if (frame.size.width > PANX)
frame.origin.x += (frame.size.width - PANX)/2.0;
frame.size.width = PANX;
if (frame.size.height > PANY)
frame.origin.y += (frame.size.height - PANY)/2.0;
frame.size.height = PANY;
panel = [GNUAlertPanel alloc];
panel = [panel initWithContentRect: frame
styleMask: 0
backing: NSBackingStoreRetained
defer: YES
screen: nil];
panel = [panel initWithContentRect:NSMakeRect(0,0,PANX,PANY)
styleMask: NSTitledWindowMask
backing: NSBackingStoreRetained
defer: YES
screen: nil];
[panel center];
#endif
}
else

View file

@ -36,7 +36,7 @@ include ../Version
LIBRARY_NAME=libgnustep-gui
# The Objective-C source files to be compiled
libgnustep-gui_OBJC_FILES = libgnustep-gui.m \
libgnustep-gui_OBJC_FILES = Functions.m \
GSContext.m \
NSActionCell.m \
NSApplication.m \

View file

@ -67,7 +67,7 @@
//
// Types
//
struct _NSModalSession {
struct _NSModalSession {
int runState;
NSWindow *window;
NSModalSession previous;
@ -96,13 +96,13 @@ static NSString *NSAbortModalException = @"NSAbortModalException";
// Initial version
[self setVersion:1];
// So the application knows
gnustep_gui_app_is_in_dealloc = NO; // its within dealloc and
gnustep_gui_app_is_in_dealloc = NO; // it's within dealloc and
} // can prevent -release
} // loops.
+ (NSApplication *)sharedApplication
{ // If the global application does
if (!NSApp) // not exist yet then create it
if (!NSApp) // not yet exist then create it
{
NSApp = [self alloc]; // Don't combine the following two
[NSApp init]; // statements into one to avoid
@ -362,12 +362,14 @@ unsigned i;
count = [event_queue count]; // that there is an
for (i = 0; i < count; i++) // event.
{
event = [event_queue objectAtIndex: i];
event = [event_queue objectAtIndex: 0];
if ([event window] == theSession->window)
{
found = YES;
break;
}
else // dump events not for
[event_queue removeObjectAtIndex:0]; // the modal window
}
if (found == NO)
@ -515,22 +517,21 @@ unsigned i;
- (void)discardEventsMatchingMask:(unsigned int)mask
beforeEvent:(NSEvent *)lastEvent
{
int i = 0, count;
int i = 0, count, loop;
NSEvent* event = nil;
BOOL match = NO;
BOOL match;
// if queue contains
if ((count = [event_queue count])) // events check them
{
for (loop = 0; ((event != lastEvent) && (loop < count)); loop++)
{
event = [event_queue objectAtIndex:i]; // Get next event from
match = NO; // the events queue
count = [event_queue count];
event = [event_queue objectAtIndex:i];
while((event != lastEvent) && (i < count))
{
if (mask == NSAnyEventMask) // any event is a match
match = YES;
else
{
if (event == null_event)
match = YES; // dump all null events
if (mask == NSAnyEventMask) // the any event mask
match = YES; // matches all events
else
{
{
switch([event type])
{
case NSLeftMouseDown:
@ -604,14 +605,15 @@ BOOL match = NO;
break;
default:
match = NO;
break;
} } } // remove event from
} } // remove event from
// the queue if it
if (match) // matched the mask
[event_queue removeObjectAtIndex:i];
event = [event_queue objectAtIndex:++i]; // get the next event
}; // in the queue
if (match) // matched the mask
[event_queue removeObjectAtIndex:i];
else // inc queue cntr only
i++; // if not a match else
} // we will run off the
} // end of the queue
}
- (NSEvent*)_eventMatchingMask:(unsigned int)mask dequeue:(BOOL)flag
@ -848,7 +850,7 @@ BOOL done = NO;
}
//
// Hiding all windows
// Hiding and arranging windows
//
- (void)hide:sender
{
@ -904,6 +906,14 @@ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
object: self];
}
- (void)arrangeInFront:sender // preliminary FIX ME
{
int i, count;
// Tell windows to unhide
for (i = 0, count = [window_list count]; i < count; i++)
[[window_list objectAtIndex:i] orderFront:sender];
}
//
// Managing windows
//
@ -1077,10 +1087,6 @@ int i;
}
}
- (void)arrangeInFront:sender
{
}
- (void)changeWindowsItem:aWindow
title:(NSString *)aString
filename:(BOOL)isFilename

View file

@ -487,6 +487,7 @@ NSString* _string;
// Target and Action
//
- (SEL)action { return NULL; }
- (void)setAction:(SEL)aSelector {}
- (BOOL)isContinuous { return cell_continuous; }
- (int)sendActionOn:(int)mask
@ -498,22 +499,14 @@ unsigned int previousMask = action_mask;
return previousMask;
}
- (void)setAction:(SEL)aSelector
{}
- (void)setContinuous:(BOOL)flag
{
cell_continuous = flag;
[self sendActionOn:(NSLeftMouseUpMask|NSPeriodicMask)];
cell_continuous = flag;
[self sendActionOn:(NSLeftMouseUpMask|NSPeriodicMask)];
}
- (void)setTarget:(id)anObject
{}
- (id)target
{
return nil;
}
- (void)setTarget:(id)anObject {}
- (id)target { return nil; }
- (void)performClick:(id)sender
{
@ -522,21 +515,13 @@ unsigned int previousMask = action_mask;
//
// Assigning a Tag
//
- (void)setTag:(int)anInt
{}
- (int)tag
{
return -1;
}
- (void)setTag:(int)anInt {}
- (int)tag { return -1; }
//
// Handling Keyboard Alternatives
//
- (NSString *)keyEquivalent
{
return nil;
}
- (NSString *)keyEquivalent { return nil; }
//
// Tracking the Mouse
@ -582,7 +567,8 @@ unsigned int previousMask = action_mask;
{
NSApplication *theApp = [NSApplication sharedApplication];
unsigned int event_mask = NSLeftMouseDownMask | NSLeftMouseUpMask |
NSMouseMovedMask | NSLeftMouseDraggedMask | NSRightMouseDraggedMask;
NSMouseMovedMask | NSLeftMouseDraggedMask |
NSRightMouseDraggedMask;
NSPoint location = [theEvent locationInWindow];
NSPoint point = [controlView convertPoint: location fromView: nil];
float delay, interval;
@ -592,169 +578,171 @@ NSPoint last_point;
BOOL done;
BOOL mouseWentUp;
NSDebugLog(@"NSCell start tracking\n");
NSDebugLog(@"NSCell tracking in rect %f %f %f %f\n",
cellFrame.origin.x, cellFrame.origin.y,
cellFrame.size.width, cellFrame.size.height);
NSDebugLog(@"NSCell initial point %f %f\n", point.x, point.y);
NSDebugLog(@"NSCell start tracking\n");
NSDebugLog(@"NSCell tracking in rect %f %f %f %f\n",
cellFrame.origin.x, cellFrame.origin.y,
cellFrame.size.width, cellFrame.size.height);
NSDebugLog(@"NSCell initial point %f %f\n", point.x, point.y);
if (![self startTrackingAt: point inView: controlView])
return NO;
if (![self startTrackingAt: point inView: controlView])
return NO;
if (![controlView mouse: point inRect: cellFrame])
return NO; // point is not in cell
if (![controlView mouse: point inRect: cellFrame])
return NO; // point is not in cell
if ([theEvent type] == NSLeftMouseDown
&& (action_mask & NSLeftMouseDownMask))
[(NSControl*)controlView sendAction:action to:target];
if ([theEvent type] == NSLeftMouseDown &&
(action_mask & NSLeftMouseDownMask))
[(NSControl*)controlView sendAction:action to:target];
if (cell_continuous) {
[self getPeriodicDelay:&delay interval:&interval];
[NSEvent startPeriodicEventsAfterDelay:delay withPeriod:interval];
event_mask |= NSPeriodicMask;
}
if (cell_continuous)
{
[self getPeriodicDelay:&delay interval:&interval];
[NSEvent startPeriodicEventsAfterDelay:delay withPeriod:interval];
event_mask |= NSPeriodicMask;
}
// Get next mouse events until a mouse up is obtained
NSDebugLog(@"NSCell get mouse events\n");
mouseWentUp = NO;
done = NO;
while (!done) {
NSEventType eventType;
BOOL pointIsInCell;
NSDebugLog(@"NSCell get mouse events\n");
mouseWentUp = NO;
done = NO;
while (!done) // Get next mouse
{ // event until a mouse
NSEventType eventType; // up is obtained
BOOL pointIsInCell;
last_point = point;
theEvent = [theApp nextEventMatchingMask:event_mask untilDate:nil
inMode:NSEventTrackingRunLoopMode dequeue:YES];
eventType = [theEvent type];
last_point = point;
theEvent = [theApp nextEventMatchingMask:event_mask
untilDate:nil
inMode:NSEventTrackingRunLoopMode
dequeue:YES];
eventType = [theEvent type];
if (eventType != NSPeriodic) {
location = [theEvent locationInWindow];
point = [controlView convertPoint: location fromView: nil];
NSDebugLog(@"NSCell location %f %f\n", location.x, location.y);
NSDebugLog(@"NSCell point %f %f\n", point.x, point.y);
}
else
NSDebugLog (@"got a periodic event");
if (eventType != NSPeriodic)
{
location = [theEvent locationInWindow];
point = [controlView convertPoint: location fromView: nil];
NSDebugLog(@"NSCell location %f %f\n", location.x, location.y);
NSDebugLog(@"NSCell point %f %f\n", point.x, point.y);
}
else
NSDebugLog (@"got a periodic event");
// Point is not in cell
if (![controlView mouse: point inRect: cellFrame])
{
NSDebugLog(@"NSCell point not in cell frame\n");
// Point is not in cell
if (![controlView mouse: point inRect: cellFrame]) {
NSDebugLog(@"NSCell point not in cell frame\n");
pointIsInCell = NO; // Do we return now or
// keep tracking?
if (![[self class] prefersTrackingUntilMouseUp] && flag)
{
NSDebugLog(@"NSCell return immediately\n");
done = YES;
}
}
else
pointIsInCell = YES; // Point is in cell
pointIsInCell = NO;
if (!done && ![self continueTracking:last_point // should continue
at:point // tracking?
inView:controlView])
{
NSDebugLog(@"NSCell stop tracking\n");
done = YES;
}
// Did the mouse go up?
if (eventType == NSLeftMouseUp)
{
NSDebugLog(@"NSCell mouse went up\n");
mouseWentUp = YES;
done = YES;
if ((action_mask & NSLeftMouseUpMask))
[(NSControl*)controlView sendAction:action to:target];
}
else
{
if (pointIsInCell && ((eventType == NSLeftMouseDragged
&& (action_mask & NSLeftMouseDraggedMask))
|| ((eventType == NSPeriodic)
&& (action_mask & NSPeriodicMask))))
[(NSControl*)controlView sendAction:action to:target];
}
}
// Tell ourselves to
[self stopTracking:last_point // stop tracking
at:point
inView:controlView
mouseIsUp:mouseWentUp];
// Do we return now or keep tracking
if (![[self class] prefersTrackingUntilMouseUp] && flag) {
NSDebugLog(@"NSCell return immediately\n");
done = YES;
}
}
else
pointIsInCell = YES; // Point is in cell
// should we continue tracking?
if (!done
&& ![self continueTracking:last_point at:point inView:controlView]) {
NSDebugLog(@"NSCell stop tracking\n");
done = YES;
}
// Did the mouse go up?
if (eventType == NSLeftMouseUp) {
NSDebugLog(@"NSCell mouse went up\n");
mouseWentUp = YES;
done = YES;
if ((action_mask & NSLeftMouseUpMask))
[(NSControl*)controlView sendAction:action to:target];
}
else {
if (pointIsInCell
&& ((eventType == NSLeftMouseDragged
&& (action_mask & NSLeftMouseDraggedMask))
|| ((eventType == NSPeriodic)
&& (action_mask & NSPeriodicMask))))
[(NSControl*)controlView sendAction:action to:target];
}
}
// Tell ourselves to stop tracking
[self stopTracking:last_point at:point
inView:controlView mouseIsUp:mouseWentUp];
if (cell_continuous)
[NSEvent stopPeriodicEvents];
// Return YES only if the mouse went up within the cell
if (mouseWentUp && [controlView mouse: point inRect: cellFrame]) {
NSDebugLog(@"NSCell mouse went up in cell\n");
return YES;
}
if (cell_continuous)
[NSEvent stopPeriodicEvents];
// Return YES only if the mouse
// went up within the cell
if (mouseWentUp && [controlView mouse: point inRect: cellFrame])
{
NSDebugLog(@"NSCell mouse went up in cell\n");
return YES;
}
#if 1
[controlView setNeedsDisplayInRect:cellFrame];
#endif
// Otherwise return NO
NSDebugLog(@"NSCell mouse did not go up in cell\n");
return NO;
NSDebugLog(@"NSCell mouse did not go up in cell\n");
return NO; // Otherwise return NO
}
//
// Managing the Cursor
//
- (void)resetCursorRect:(NSRect)cellFrame
inView:(NSView *)controlView
{}
- (void)resetCursorRect:(NSRect)cellFrame inView:(NSView *)controlView
{
}
//
// Comparing to Another NSCell
//
- (NSComparisonResult)compare:(id)otherCell
{
return 0;
return 0;
}
//
// Using the NSCell to Represent an Object
//
- (id)representedObject
{
return represented_object;
}
- (id)representedObject { return represented_object; }
- (void)setRepresentedObject:(id)anObject
{
ASSIGN(represented_object, anObject);
ASSIGN(represented_object, anObject);
}
- (id)copyWithZone:(NSZone*)zone
{
NSCell* c = [[isa allocWithZone: zone] init];
NSCell* c = [[isa allocWithZone: zone] init];
c->contents = [[contents copy] retain];
ASSIGN(c->cell_image, cell_image);
ASSIGN(c->cell_font, cell_font);
c->cell_state = cell_state;
c->cell_highlighted = cell_highlighted;
c->cell_enabled = cell_enabled;
c->cell_editable = cell_editable;
c->cell_bordered = cell_bordered;
c->cell_bezeled = cell_bezeled;
c->cell_scrollable = cell_scrollable;
c->cell_selectable = cell_selectable;
[c setContinuous:cell_continuous];
c->cell_float_autorange = cell_float_autorange;
c->cell_float_left = cell_float_left;
c->cell_float_right = cell_float_right;
c->image_position = image_position;
c->cell_type = cell_type;
c->text_align = text_align;
c->entry_type = entry_type;
c->control_view = control_view;
c->cell_size = cell_size;
[c setRepresentedObject:represented_object];
return c;
c->contents = [[contents copy] retain];
ASSIGN(c->cell_image, cell_image);
ASSIGN(c->cell_font, cell_font);
c->cell_state = cell_state;
c->cell_highlighted = cell_highlighted;
c->cell_enabled = cell_enabled;
c->cell_editable = cell_editable;
c->cell_bordered = cell_bordered;
c->cell_bezeled = cell_bezeled;
c->cell_scrollable = cell_scrollable;
c->cell_selectable = cell_selectable;
[c setContinuous:cell_continuous];
c->cell_float_autorange = cell_float_autorange;
c->cell_float_left = cell_float_left;
c->cell_float_right = cell_float_right;
c->image_position = image_position;
c->cell_type = cell_type;
c->text_align = text_align;
c->entry_type = entry_type;
c->control_view = control_view;
c->cell_size = cell_size;
[c setRepresentedObject:represented_object];
return c;
}
//
@ -816,10 +804,9 @@ BOOL mouseWentUp;
//
@implementation NSCell (GNUstepBackend)
// Returns the size of a border
+ (NSSize)sizeForBorderType:(NSBorderType)aType
{
return NSZeroSize;
{ // Returns the size of a
return NSZeroSize; // border
}
@end

View file

@ -357,15 +357,14 @@ static id MB_NSCONTROL_CELL_CLASS = nil;
return [cell isContinuous];
}
- (BOOL)sendAction:(SEL)theAction
to:(id)theTarget
- (BOOL)sendAction:(SEL)theAction to:(id)theTarget
{
NSApplication *theApp = [NSApplication sharedApplication];
NSApplication *theApp = [NSApplication sharedApplication];
if (theAction && theTarget)
return [theApp sendAction:theAction to:theTarget from:self];
else
return NO;
if (theAction && theTarget)
return [theApp sendAction:theAction to:theTarget from:self];
else
return NO;
}
- (int)sendActionOn:(int)mask

View file

@ -420,11 +420,11 @@ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
- (void)center
{
NSSize screenSize = [[NSScreen mainScreen] frame].size;
NSRect n = frame; // center the window
NSPoint origin = frame.origin; // center the window
// within it's screen
n.origin.x = (screenSize.width - frame.size.width) / 2;
n.origin.y = (screenSize.height - frame.size.height) / 2;
[self setFrame:n display:YES];
origin.x = (screenSize.width - frame.size.width) / 2;
origin.y = (screenSize.height - frame.size.height) / 2;
[self setFrameOrigin:origin];
}
- (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:screen