Corrections for state changes and drawing with cells and controls.

Corrections to NSWindow for key and main window notification and
first responder handling.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@1642 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
GNUstep Maintainer 1996-07-10 20:43:47 +00:00
parent e2228d0274
commit 6ec5d8d5a4
6 changed files with 140 additions and 101 deletions

View file

@ -1,3 +1,15 @@
Wed Jun 26 12:43:17 1996 GNUstep Development <gnustep@duncan.ocbi.com>
* Source/NSButton.m (mouseDown:): Correct cell state changes for
the different cell types.
* Source/NSActionCell.m (setState:): Update the cell.
* Source/NSControl.m (drawCell:, drawCellInside:): Pass the
control's bounds not its frame.
* Source/NSTextFieldCell.m (initTextCell:): Make the default
background color be white.
* Source/NSWindow.m: Corrections to key and main window
notification and first responder handling.
Fri Jun 21 11:09:50 1996 GNUstep Development <gnustep@duncan.ocbi.com>
* Headers/gnustep/gui/NSScreen.h: Add instance variables for

View file

@ -139,6 +139,17 @@
[(NSControl *)control_view updateCell: self];
}
//
// Setting the NSCell's State
//
- (void)setState:(int)value
{
[super setState: value];
if (control_view)
if ([control_view isKindOfClass: [NSControl class]])
[(NSControl *)control_view updateCell: self];
}
//
// Manipulating NSActionCell Values
//

View file

@ -258,77 +258,81 @@ id MB_NSBUTTON_CLASS;
//
- (void)mouseDown:(NSEvent *)theEvent
{
NSApplication *theApp = [NSApplication sharedApplication];
BOOL mouseUp, done;
NSEvent *e;
unsigned int event_mask = NSLeftMouseDownMask | NSLeftMouseUpMask |
NSMouseMovedMask | NSLeftMouseDraggedMask | NSRightMouseDraggedMask;
NSApplication *theApp = [NSApplication sharedApplication];
BOOL mouseUp, done;
NSEvent *e;
unsigned int event_mask = NSLeftMouseDownMask | NSLeftMouseUpMask |
NSMouseMovedMask | NSLeftMouseDraggedMask | NSRightMouseDraggedMask;
NSDebugLog(@"NSButton mouseDown\n");
NSDebugLog(@"NSButton mouseDown\n");
// If we are not enabled then ignore the mouse
if (![self isEnabled])
return;
// If we are not enabled then ignore the mouse
if (![self isEnabled])
return;
// capture mouse
[[self window] captureMouse: self];
// capture mouse
[[self window] captureMouse: self];
done = NO;
e = theEvent;
while (!done)
{
mouseUp = [cell trackMouse: e inRect: bounds
ofView:self untilMouseUp:YES];
e = [theApp currentEvent];
done = NO;
e = theEvent;
while (!done)
{
mouseUp = [cell trackMouse: e inRect: bounds
ofView:self untilMouseUp:YES];
e = [theApp currentEvent];
// If mouse went up then we are done
if ((mouseUp) || ([e type] == NSLeftMouseUp))
done = YES;
else
{
NSDebugLog(@"NSButton process another event\n");
e = [theApp nextEventMatchingMask:event_mask untilDate:nil
inMode:nil dequeue:YES];
}
}
// If mouse went up then we are done
if ((mouseUp) || ([e type] == NSLeftMouseUp))
done = YES;
else
{
NSDebugLog(@"NSButton process another event\n");
e = [theApp nextEventMatchingMask:event_mask untilDate:nil
inMode:nil dequeue:YES];
}
}
// Release mouse
[[self window] releaseMouse: self];
// Release mouse
[[self window] releaseMouse: self];
// If the mouse went up in the button
if (mouseUp)
{
// Unhighlight the button
[cell highlight: NO withFrame: bounds
inView: self];
// If the mouse went up in the button
if (mouseUp)
{
// Unhighlight the button
[cell highlight: NO withFrame: bounds
inView: self];
//
// Perform different state changes based upon our type
//
switch ([cell type])
{
case NSMomentaryChangeButton:
case NSPushOnPushOffButton:
case NSToggleButton:
case NSSwitchButton:
case NSRadioButton:
case NSOnOffButton:
// Toggle our state
if ([self state])
{
[self setState:0];
NSDebugLog(@"toggle state off\n");
}
else
{
[self setState:1];
NSDebugLog(@"toggle state on\n");
}
}
//
// Perform different state changes based upon our type
//
switch ([cell type])
{
case NSToggleButton:
case NSMomentaryChangeButton:
case NSMomentaryPushButton:
/* No state changes */
break;
// Have the target perform the action
[self sendAction:[self action] to:[self target]];
}
case NSPushOnPushOffButton:
case NSSwitchButton:
case NSRadioButton:
case NSOnOffButton:
// Toggle our state
if ([self state])
{
[cell setState:0];
NSDebugLog(@"toggle state off\n");
}
else
{
[cell setState:1];
NSDebugLog(@"toggle state on\n");
}
}
// Have the target perform the action
[self sendAction:[self action] to:[self target]];
}
}
- (void)performClick:(id)sender

View file

@ -280,12 +280,12 @@ right:(unsigned)rightDigits
//
- (void)drawCell:(NSCell *)aCell
{
if (cell == aCell) [cell drawWithFrame:frame inView:self];
if (cell == aCell) [cell drawWithFrame:bounds inView:self];
}
- (void)drawCellInside:(NSCell *)aCell
{
if (cell == aCell) [cell drawInteriorWithFrame:frame inView:self];
if (cell == aCell) [cell drawInteriorWithFrame:bounds inView:self];
}
- (void)selectCell:(NSCell *)aCell

View file

@ -76,7 +76,7 @@
[self setEditable:YES];
[self setAlignment:NSLeftTextAlignment];
background_color = [NSColor grayColor];
background_color = [NSColor whiteColor];
text_color = [NSColor blackColor];
return self;
}

View file

@ -174,7 +174,7 @@ NSString *NSWindowWillMoveNotification;
// Initialize attributes and flags
frame_view = nil;
[self setContentView:[[NSView alloc] initWithFrame:frame]];
first_responder = self;
first_responder = nil;
delegate = nil;
window_num = 0;
background_color = [NSColor grayColor];
@ -350,21 +350,19 @@ NSString *NSWindowWillMoveNotification;
//
- (void)becomeKeyWindow
{
// Can we become the key window
if (![self canBecomeKeyWindow]) return;
// We are the key window
is_key = YES;
// Yes well then do it
[self makeKeyWindow];
// Post notification
[self windowDidBecomeKey:self];
}
- (void)becomeMainWindow
{
// Can we become the main window
if (![self canBecomeMainWindow]) return;
// We are the main window
is_main = YES;
// Yes well then do it
[self makeMainWindow];
// Post notification
[self windowDidBecomeMain:self];
}
@ -410,19 +408,8 @@ NSString *NSWindowWillMoveNotification;
- (void)makeKeyAndOrderFront:sender
{
id w;
NSApplication *theApp = [NSApplication sharedApplication];
// Can we become the key window?
if ([self canBecomeKeyWindow])
{
// Tell the current key window to resign
w = [theApp keyWindow];
[w resignKeyWindow];
// Now we should become the key window
[self becomeKeyWindow];
}
// Make ourself the key window
[self makeKeyWindow];
// Now order to the front
[self orderFront:sender];
@ -430,12 +417,30 @@ NSString *NSWindowWillMoveNotification;
- (void)makeKeyWindow
{
is_key = YES;
NSApplication *theApp = [NSApplication sharedApplication];
// Can we become the key window
if (![self canBecomeKeyWindow]) return;
// Make the current key window resign
[[theApp keyWindow] resignKeyWindow];
// Make ourself become the key window
[self becomeKeyWindow];
}
- (void)makeMainWindow
{
is_main = YES;
NSApplication *theApp = [NSApplication sharedApplication];
// Can we become the main window
if (![self canBecomeMainWindow]) return;
// Make the current main window resign
[[theApp mainWindow] resignMainWindow];
// Make ourself become the main window
[self becomeMainWindow];
}
- (void)orderBack:sender
@ -465,11 +470,17 @@ NSString *NSWindowWillMoveNotification;
- (void)resignKeyWindow
{
is_key = NO;
// Post notification
[self windowDidResignKey: self];
}
- (void)resignMainWindow
{
is_main = NO;
// Post notification
[self windowDidResignMain: self];
}
- (void)setHidesOnDeactivate:(BOOL)flag
@ -754,20 +765,21 @@ NSString *NSWindowWillMoveNotification;
if (first_responder == aResponder)
return YES;
// If not a NSResponder then forget it
// If not a NSResponder then forget it
if (![aResponder isKindOfClass:[NSResponder class]])
return NO;
// Does it accept the first responder?
// Does it accept the first responder?
if (![aResponder acceptsFirstResponder])
return NO;
// Notify current first responder that it should resign
// If it says NO then no change
if (![first_responder resignFirstResponder])
// Notify current first responder that it should resign
// If it says NO then no change
// But make sure that there even is a first responder
if ((![first_responder resignFirstResponder]) && first_responder)
return NO;
// Make it the first responder
// Make it the first responder
first_responder = aResponder;
// Notify it that it just became the first responder
@ -788,7 +800,7 @@ NSString *NSWindowWillMoveNotification;
- (NSEvent *)nextEventMatchingMask:(unsigned int)mask
untilDate:(NSDate *)expiration
inMode:(NSString *)mode
inMode:(NSString *)mode
dequeue:(BOOL)deqFlag
{
return nil;
@ -1014,11 +1026,11 @@ inMode:(NSString *)mode
//
- (void)dragImage:(NSImage *)anImage
at:(NSPoint)baseLocation
offset:(NSSize)initialOffset
event:(NSEvent *)event
pasteboard:(NSPasteboard *)pboard
source:sourceObject
slideBack:(BOOL)slideFlag
offset:(NSSize)initialOffset
event:(NSEvent *)event
pasteboard:(NSPasteboard *)pboard
source:sourceObject
slideBack:(BOOL)slideFlag
{}
- (void)registerForDraggedTypes:(NSArray *)newTypes