Minor bug fixes related to lock/unlock of focus and

displaying cells when their value has changed.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@2257 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
netcrep 1997-03-21 01:06:15 +00:00
parent bec518f970
commit fe5dc912f5
5 changed files with 43 additions and 53 deletions

View file

@ -1,6 +1,8 @@
Thu Mar 20 10:40:51 1997 GNUstep Development <gnustep@net-community.com> Thu Mar 20 10:40:51 1997 GNUstep Development <gnustep@net-community.com>
* Source/NSControl.m (-copyWithZone:): Copy the object instead of * Source/NSControl.m: Call displayIfNeeded after setting the
contents of the cell.
(-copyWithZone:): Copy the object instead of
allocating so that instance variable values are copied. Retain allocating so that instance variable values are copied. Retain
the cell because it will be released when we set a new one. the cell because it will be released when we set a new one.
(-drawCell:, -drawCellInside:): Lock and unlock the focus (-drawCell:, -drawCellInside:): Lock and unlock the focus
@ -14,17 +16,23 @@ Thu Mar 20 10:40:51 1997 GNUstep Development <gnustep@net-community.com>
for obtaining the extension. for obtaining the extension.
* Source/NSScroller.m (-setFloatValue:knobProportion:): Set knob * Source/NSScroller.m (-setFloatValue:knobProportion:): Set knob
proportion first before setting float value. proportion first before setting float value.
(-setFloatValue:): Indicate needs display.
(-drawRect:): Remove method. (-drawRect:): Remove method.
(-drawParts): Flush window. (-drawParts): Flush window.
(-trackKnob:): Correct position of knob relative to pointer. (-trackKnob:): Correct position of knob relative to pointer. Lock
and unlock the focus; make sure it is unlocked before sending action.
(-trackScrollButtons:): Fill out implementation. (-trackScrollButtons:): Fill out implementation.
(-mouseDown:): Lock and unlock focus. (-mouseDown:): Lock and unlock focus in the tracking methods instead.
* Source/NSTextField.m (-setTextCursor:, -copyWithZone:): New methods. * Source/NSTextField.m (-setTextCursor:, -copyWithZone:): New methods.
* Source/NSTextFieldCell.m (-initTextCell:): By default * Source/NSTextFieldCell.m (-initTextCell:): By default
it draws the background. it draws the background.
* Source/NSView.m (-ancestoreSharedWithView:): Implement. * Source/NSView.m (-ancestoreSharedWithView:): Implement.
(-lockFocus, -unlockFocus): Make sure our superview locks or unlocks (-lockFocus, -unlockFocus): Make sure our superview locks or unlocks
the focus before us. the focus before us.
(-display): Unlock focus before drawing subviews.
(+popFocusView): Returned poped view.
* Source/NSButton.m (-mouseDown:): Remove unneeded code; rearrange
so that the focus is unlocked before sending the action.
Fri Mar 14 18:23:18 1997 Ovidiu Predescu <ovidiu@net-community.com> Fri Mar 14 18:23:18 1997 Ovidiu Predescu <ovidiu@net-community.com>

View file

@ -325,46 +325,15 @@ id gnustep_gui_nsbutton_class = nil;
[cell highlight: NO withFrame: bounds [cell highlight: NO withFrame: bounds
inView: self]; inView: self];
#if 0
//
// Perform different state changes based upon our type
//
switch ([cell type])
{
case NSToggleButton:
case NSMomentaryChangeButton:
case NSMomentaryPushButton:
/* No state changes */
break;
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");
}
default:
break;
}
#endif
[cell setState:![self state]]; [cell setState:![self state]];
// Have the target perform the action
[self sendAction:[self action] to:[self target]];
[cell drawWithFrame:bounds inView:self]; [cell drawWithFrame:bounds inView:self];
[[self window] flushWindow];
} }
[[self window] flushWindow];
[self unlockFocus]; [self unlockFocus];
// Have the target perform the action
if (mouseUp)
[self sendAction:[self action] to:[self target]];
} }
- (void)performClick:(id)sender - (void)performClick:(id)sender

View file

@ -181,16 +181,19 @@ NSString *NSControlTextDidChangeNotification = @"NSControlTextDidChangeNotificat
- (void)setDoubleValue:(double)aDouble - (void)setDoubleValue:(double)aDouble
{ {
[[self selectedCell] setDoubleValue:aDouble]; [[self selectedCell] setDoubleValue:aDouble];
[self displayIfNeeded];
} }
- (void)setFloatValue:(float)aFloat - (void)setFloatValue:(float)aFloat
{ {
[[self selectedCell] setFloatValue:aFloat]; [[self selectedCell] setFloatValue:aFloat];
[self displayIfNeeded];
} }
- (void)setIntValue:(int)anInt - (void)setIntValue:(int)anInt
{ {
[[self selectedCell] setIntValue:anInt]; [[self selectedCell] setIntValue:anInt];
[self displayIfNeeded];
} }
- (void)setNeedsDisplay - (void)setNeedsDisplay
@ -201,6 +204,7 @@ NSString *NSControlTextDidChangeNotification = @"NSControlTextDidChangeNotificat
- (void)setStringValue:(NSString *)aString - (void)setStringValue:(NSString *)aString
{ {
[[self selectedCell] setStringValue:aString]; [[self selectedCell] setStringValue:aString];
[self displayIfNeeded];
} }
- (NSString *)stringValue - (NSString *)stringValue
@ -214,21 +218,25 @@ NSString *NSControlTextDidChangeNotification = @"NSControlTextDidChangeNotificat
- (void)takeDoubleValueFrom:(id)sender - (void)takeDoubleValueFrom:(id)sender
{ {
[[self selectedCell] takeDoubleValueFrom:sender]; [[self selectedCell] takeDoubleValueFrom:sender];
[self displayIfNeeded];
} }
- (void)takeFloatValueFrom:(id)sender - (void)takeFloatValueFrom:(id)sender
{ {
[[self selectedCell] takeFloatValueFrom:sender]; [[self selectedCell] takeFloatValueFrom:sender];
[self displayIfNeeded];
} }
- (void)takeIntValueFrom:(id)sender - (void)takeIntValueFrom:(id)sender
{ {
[[self selectedCell] takeIntValueFrom:sender]; [[self selectedCell] takeIntValueFrom:sender];
[self displayIfNeeded];
} }
- (void)takeStringValueFrom:(id)sender - (void)takeStringValueFrom:(id)sender
{ {
[[self selectedCell] takeStringValueFrom:sender]; [[self selectedCell] takeStringValueFrom:sender];
[self displayIfNeeded];
} }
// //
@ -262,7 +270,7 @@ NSString *NSControlTextDidChangeNotification = @"NSControlTextDidChangeNotificat
- (void)setFloatingPointFormat:(BOOL)autoRange - (void)setFloatingPointFormat:(BOOL)autoRange
left:(unsigned)leftDigits left:(unsigned)leftDigits
right:(unsigned)rightDigits right:(unsigned)rightDigits
{} {}
// //
@ -321,13 +329,11 @@ right:(unsigned)rightDigits
- (void)updateCell:(NSCell *)aCell - (void)updateCell:(NSCell *)aCell
{ {
[self setNeedsDisplay:YES]; [self setNeedsDisplay:YES];
// [self drawCell:aCell];
} }
- (void)updateCellInside:(NSCell *)aCell - (void)updateCellInside:(NSCell *)aCell
{ {
[self setNeedsDisplay:YES]; [self setNeedsDisplay:YES];
// [self drawCellInside:aCell];
} }
// //

View file

@ -156,6 +156,7 @@ id gnustep_gui_nsscroller_class = nil;
aFloat = 0; aFloat = 0;
if (aFloat > 1) if (aFloat > 1)
aFloat = 1; aFloat = 1;
[self setNeedsDisplay];
[super setFloatValue: aFloat]; [super setFloatValue: aFloat];
} }
@ -275,6 +276,8 @@ id gnustep_gui_nsscroller_class = nil;
NSRect barRect = [self boundsOfScrollerPart: NSScrollerKnobSlot]; NSRect barRect = [self boundsOfScrollerPart: NSScrollerKnobSlot];
float pos; float pos;
[self lockFocus];
// capture mouse // capture mouse
[[self window] captureMouse: self]; [[self window] captureMouse: self];
@ -318,12 +321,13 @@ id gnustep_gui_nsscroller_class = nil;
// Release mouse // Release mouse
[[self window] releaseMouse: self]; [[self window] releaseMouse: self];
// Have the target perform the action
[self sendAction:[self action] to:[self target]];
// Update the display // Update the display
[self drawParts]; [self drawParts];
[self unlockFocus];
[[self window] flushWindow]; [[self window] flushWindow];
// Have the target perform the action
[self sendAction:[self action] to:[self target]];
} }
- (void)trackScrollButtons:(NSEvent *)theEvent - (void)trackScrollButtons:(NSEvent *)theEvent
@ -354,6 +358,8 @@ id gnustep_gui_nsscroller_class = nil;
break; break;
} }
[self lockFocus];
// capture mouse // capture mouse
[[self window] captureMouse: self]; [[self window] captureMouse: self];
@ -414,14 +420,16 @@ id gnustep_gui_nsscroller_class = nil;
// unhighlight arrow // unhighlight arrow
[self drawArrow: arrow highlight: NO]; [self drawArrow: arrow highlight: NO];
[[self window] flushWindow]; [[self window] flushWindow];
// Have the target perform the action
[self sendAction:[self action] to:[self target]];
} }
// Update the display // Update the display
[self drawParts]; [self drawParts];
[self unlockFocus];
[[self window] flushWindow]; [[self window] flushWindow];
// Have the target perform the action
if ([self mouse: point inRect: partRect])
[self sendAction:[self action] to:[self target]];
} }
// //
@ -457,8 +465,6 @@ id gnustep_gui_nsscroller_class = nil;
// We must have hit a real part so record it // We must have hit a real part so record it
hit_part = area; hit_part = area;
[self lockFocus];
// Track the knob if that's where it hit // Track the knob if that's where it hit
if ((hit_part == NSScrollerKnob) || (hit_part == NSScrollerKnobSlot)) if ((hit_part == NSScrollerKnob) || (hit_part == NSScrollerKnobSlot))
[self trackKnob: theEvent]; [self trackKnob: theEvent];
@ -469,8 +475,6 @@ id gnustep_gui_nsscroller_class = nil;
(hit_part == NSScrollerIncrementPage) || (hit_part == NSScrollerIncrementPage) ||
(hit_part == NSScrollerIncrementLine)) (hit_part == NSScrollerIncrementLine))
[self trackScrollButtons: theEvent]; [self trackScrollButtons: theEvent];
[self unlockFocus];
} }
// //

View file

@ -99,14 +99,17 @@ NSString *NSViewFocusChangedNotification = @"NSViewFocusChangedNotification";
+ (NSView *)popFocusView + (NSView *)popFocusView
{ {
NSThread *current_thread = [NSThread currentThread]; NSThread *current_thread = [NSThread currentThread];
id v;
// Obtain lock so we can edit the dictionary // Obtain lock so we can edit the dictionary
[gnustep_gui_nsview_lock lock]; [gnustep_gui_nsview_lock lock];
// Remove from dictionary // Remove from dictionary
v = [gnustep_gui_nsview_thread_dict objectForKey: current_thread];
[gnustep_gui_nsview_thread_dict removeObjectForKey: current_thread]; [gnustep_gui_nsview_thread_dict removeObjectForKey: current_thread];
[gnustep_gui_nsview_lock unlock]; [gnustep_gui_nsview_lock unlock];
return v;
} }
+ (NSView *)focusView + (NSView *)focusView
@ -789,13 +792,13 @@ NSString *NSViewFocusChangedNotification = @"NSViewFocusChangedNotification";
[self lockFocus]; [self lockFocus];
[self drawRect:bounds]; [self drawRect:bounds];
[self unlockFocus];
// Tell subviews to display // Tell subviews to display
j = [sub_views count]; j = [sub_views count];
for (i = 0;i < j; ++i) for (i = 0;i < j; ++i)
[(NSView *)[sub_views objectAtIndex:i] display]; [(NSView *)[sub_views objectAtIndex:i] display];
[[self window] flushWindow]; [[self window] flushWindow];
[self unlockFocus];
} }
- (void)displayIfNeeded - (void)displayIfNeeded