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:
Scott Christley 1997-03-21 01:06:15 +00:00
parent aa3bf02466
commit b44d89e34a
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>
* 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
the cell because it will be released when we set a new one.
(-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.
* Source/NSScroller.m (-setFloatValue:knobProportion:): Set knob
proportion first before setting float value.
(-setFloatValue:): Indicate needs display.
(-drawRect:): Remove method.
(-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.
(-mouseDown:): Lock and unlock focus.
(-mouseDown:): Lock and unlock focus in the tracking methods instead.
* Source/NSTextField.m (-setTextCursor:, -copyWithZone:): New methods.
* Source/NSTextFieldCell.m (-initTextCell:): By default
it draws the background.
* Source/NSView.m (-ancestoreSharedWithView:): Implement.
(-lockFocus, -unlockFocus): Make sure our superview locks or unlocks
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>

View file

@ -325,46 +325,15 @@ id gnustep_gui_nsbutton_class = nil;
[cell highlight: NO withFrame: bounds
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]];
// Have the target perform the action
[self sendAction:[self action] to:[self target]];
[cell drawWithFrame:bounds inView:self];
[[self window] flushWindow];
}
[[self window] flushWindow];
[self unlockFocus];
// Have the target perform the action
if (mouseUp)
[self sendAction:[self action] to:[self target]];
}
- (void)performClick:(id)sender

View file

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

View file

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

View file

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