diff --git a/ChangeLog b/ChangeLog index 1d555e052..a686ba34a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,40 @@ +Tue Sep 15 1999 Nicola Pero + + (NB. The above date reflects submission of the patch - sorry I didn't + commit it until 21st Sept - RFM) + * Source/NSButton.m ([-performClick:]): Removed lock/unlock focus, + now done automatically by the cell. + * Source/NSBrowserCell.m ([-drawInteriorWithFrame:inView:]): Lock + focus in the view during drawing. + * Source/NSButtonCell.m: ([-drawInteriorWithFrame:inView:]): Lock + focus in the view during drawing. ([-drawWithFrame:inView:]): + idem. + * Source/NSButtonCell.m ([-performClick:]): draw in its control_view, + if it has one, not in the currently focused view. + * Source/NSCell.m ([-performClick:]): idem. + * Source/NSCell.m: ([-drawInteriorWithFrame:inView:]): Lock focus + in the view during drawing. ([-drawWithFrame:inView:]): idem. + * Source/NSControl.m ([-initWithFrame:]): invoke +cellClass + when creating the new cell. + * Source/NSControl.m ([-drawCellInside:]): call the cell's + drawingRectForBounds: method to get the area to draw. + * Source/NSControl.m ([-mouseDown:]): Removed lock/unlock focus + now done automatically by the cell. + * Source/NSImageCell.m: ([-drawInteriorWithFrame:inView:]): Lock + focus in the view during drawing. ([-drawWithFrame:inView:]): idem. + * Source/NSMatrix.m ([-highlightCell:atRow:column:]): lock focus + during drawing of background. + * Source/NSMatrix.m ([-_mouseDownNonListMode:]): Removed lock + focus now done by the cells. ([-mouseDown:]): idem. ([-keyDown:]): + idem. + * Source/NSMenuItemCell.m ([-drawWithFrame:inView:]): Lock focus + in the view during drawing. + * Source/NSPopUpButtonCell.m ([-drawWithFrame:inView:]): idem. + * Source/NSSliderCell.m ([-drawInteriorWithFrame:inView:]): idem. + * Source/NSTableHeaderCell.m ([-drawInteriorWithFrame:inView:]): + idem. + * Source/NSTextFieldCell.m: ([-drawInteriorWithFrame:inView:]): idem. + Mon Sep 20 1999 Nicola Pero * Source/NSView.m ([-setFrameSize:]): use zero width or height if diff --git a/Source/NSBrowserCell.m b/Source/NSBrowserCell.m index d914a01f0..ecef5602b 100644 --- a/Source/NSBrowserCell.m +++ b/Source/NSBrowserCell.m @@ -275,6 +275,7 @@ static Class colorClass; NSColor *backColor; control_view = controlView; // remember last view cell was drawn in + [controlView lockFocus]; if (cell_highlighted || cell_state) // temporary hack FAR FIX ME? { backColor = [colorClass selectedControlColor]; @@ -327,6 +328,7 @@ static Class colorClass; position.y += [image size].height; [image compositeToPoint: position operation: NSCompositeCopy]; } + [controlView unlockFocus]; } /* diff --git a/Source/NSButton.m b/Source/NSButton.m index 730630d6e..9f4c7b039 100644 --- a/Source/NSButton.m +++ b/Source/NSButton.m @@ -304,9 +304,7 @@ id _nsbuttonCellClass = nil; - (void) performClick: (id)sender { - [self lockFocus]; [cell performClick: sender]; - [self unlockFocus]; } - (BOOL) performKeyEquivalent: (NSEvent *)anEvent diff --git a/Source/NSButtonCell.m b/Source/NSButtonCell.m index 52a54f25c..57af02457 100644 --- a/Source/NSButtonCell.m +++ b/Source/NSButtonCell.m @@ -185,7 +185,12 @@ - (void) performClick: (id)sender { - NSView *cv = [NSView focusView]; + NSView *cv; + + if (control_view) + cv = control_view; + else + cv = [NSView focusView]; [self highlight: YES withFrame: [cv frame] inView: cv]; if (action) @@ -397,6 +402,7 @@ // draw the border if needed if ([self isBordered]) { + [controlView lockFocus]; if ([self isHighlighted] && ([self highlightsBy] & NSPushInCellMask)) { NSDrawGrayBezel(cellFrame, NSZeroRect); @@ -405,6 +411,7 @@ { NSDrawButton(cellFrame, NSZeroRect); } + [controlView unlockFocus]; } [self drawInteriorWithFrame: cellFrame inView: controlView]; @@ -426,6 +433,7 @@ return; cellFrame = [self drawingRectForBounds: cellFrame]; + [controlView lockFocus]; // pushed in buttons contents are displaced to the bottom right 1px if ([self isBordered] && [self isHighlighted] @@ -562,6 +570,7 @@ { [self _drawText: titleToDisplay inFrame: titleRect]; } + [controlView unlockFocus]; } - (NSSize) cellSize diff --git a/Source/NSCell.m b/Source/NSCell.m index bc274aac3..b03263d6c 100644 --- a/Source/NSCell.m +++ b/Source/NSCell.m @@ -684,7 +684,8 @@ static Class cellClass; - (void) drawInteriorWithFrame: (NSRect)cellFrame inView: (NSView*)controlView { cellFrame = [self drawingRectForBounds: cellFrame]; - + [controlView lockFocus]; + // Clear the cell frame if ([self isOpaque]) { @@ -730,6 +731,7 @@ static Class cellClass; case NSNullCellType: break; } + [controlView unlockFocus]; } - (void) drawWithFrame: (NSRect)cellFrame inView: (NSView*)controlView @@ -743,6 +745,7 @@ static Class cellClass; if (NSIsEmptyRect(cellFrame)) return; + [controlView lockFocus]; // draw the border if needed if ([self isBordered]) { @@ -754,6 +757,7 @@ static Class cellClass; NSDrawWhiteBezel(cellFrame, NSZeroRect); } + [controlView unlockFocus]; [self drawInteriorWithFrame: cellFrame inView: controlView]; } @@ -820,7 +824,12 @@ static Class cellClass; - (void) performClick: (id)sender { - NSView *cv = [NSView focusView]; + NSView *cv; + + if (control_view) + cv = control_view; + else + cv = [NSView focusView]; NSLog(@"performClick:"); diff --git a/Source/NSControl.m b/Source/NSControl.m index 69346d820..2c2d2ca1a 100644 --- a/Source/NSControl.m +++ b/Source/NSControl.m @@ -77,7 +77,7 @@ static Class cellClass; - (id) initWithFrame: (NSRect)frameRect { [super initWithFrame: frameRect]; - [self setCell: AUTORELEASE([cellClass new])]; + [self setCell: AUTORELEASE([[[self class] cellClass] new])]; tag = 0; return self; @@ -319,7 +319,8 @@ static Class cellClass; { if (cell == aCell) { - [cell drawInteriorWithFrame: bounds inView: self]; + [cell drawInteriorWithFrame: [cell drawingRectForBounds: bounds] + inView: self]; } } @@ -413,7 +414,6 @@ static Class cellClass; unsigned int event_mask = NSLeftMouseDownMask | NSLeftMouseUpMask | NSMouseMovedMask | NSLeftMouseDraggedMask | NSRightMouseDraggedMask; - NSDebugLog(@"NSControl mouseDown\n"); if (![self isEnabled]) @@ -426,8 +426,6 @@ static Class cellClass; [window _captureMouse: self]; - [self lockFocus]; - e = theEvent; while (!done) // loop until mouse goes up { @@ -472,7 +470,7 @@ static Class cellClass; [cell highlight: NO withFrame: bounds inView: self]; [window flushWindow]; } - [self unlockFocus]; + [cell sendActionOn: oldActionMask]; if (mouseUp) diff --git a/Source/NSImageCell.m b/Source/NSImageCell.m index 09b2fce8e..3094a2964 100644 --- a/Source/NSImageCell.m +++ b/Source/NSImageCell.m @@ -122,7 +122,8 @@ // do nothing if cell's frame rect is zero if( NSIsEmptyRect(cellFrame) ) return; - + + [controlView lockFocus]; // draw the border if needed switch( [self imageFrameStyle] ) { @@ -144,6 +145,7 @@ } [self drawInteriorWithFrame: cellFrame inView: controlView]; + [controlView unlockFocus]; } static inline float xLeftInRect(NSSize innerSize, NSRect outerRect) @@ -210,6 +212,7 @@ static inline NSSize scaleProportionally(NSSize imageSize, NSRect canvasRect) // leave room for the frame cellFrame = [self drawingRectForBounds: cellFrame]; + [controlView lockFocus]; switch( [self imageScaling] ) { @@ -287,6 +290,7 @@ static inline NSSize scaleProportionally(NSSize imageSize, NSRect canvasRect) // draw! [image compositeToPoint: position operation: NSCompositeCopy]; + [controlView unlockFocus]; } - (NSSize) cellSize diff --git a/Source/NSMatrix.m b/Source/NSMatrix.m index 2f9fb6d08..c19686da7 100644 --- a/Source/NSMatrix.m +++ b/Source/NSMatrix.m @@ -1289,8 +1289,10 @@ fprintf(stderr, " NSMatrix: selectTextAtRow --- "); if (drawsCellBackground) { + [self lockFocus]; [cellBackgroundColor set]; NSRectFill(cellFrame); + [self unlockFocus]; } [aCell highlight: flag withFrame: cellFrame @@ -1386,8 +1388,6 @@ fprintf(stderr, " NSMatrix: selectTextAtRow --- "); unsigned eventMask = NSLeftMouseUpMask | NSLeftMouseDownMask | NSMouseMovedMask | NSLeftMouseDraggedMask; - [self lockFocus]; - if ((mode == NSRadioModeMatrix) && selectedCell) { [selectedCell setState: NSOffState]; @@ -1499,8 +1499,6 @@ fprintf(stderr, " NSMatrix: selectTextAtRow --- "); column: highlightedColumn]; [window flushWindow]; } - - [self unlockFocus]; } @@ -1533,7 +1531,6 @@ fprintf(stderr, " NSMatrix: selectTextAtRow --- "); [NSEvent startPeriodicEventsAfterDelay: 0.05 withPeriod: 0.05]; ASSIGN(lastEvent, theEvent); - [self lockFocus]; // selection involves two steps, first // a loop that continues until the left mouse goes up; then a series of // steps which send actions and display the cell as it should appear after @@ -1743,8 +1740,6 @@ fprintf(stderr, " NSMatrix: selectTextAtRow --- "); if (target && doubleAction && ([lastEvent clickCount] > 1)) [target performSelector: doubleAction withObject: self]; - [self unlockFocus]; - if ((mode != NSTrackModeMatrix) && (mode != NSHighlightModeMatrix)) [NSEvent stopPeriodicEvents]; @@ -2051,14 +2046,11 @@ fprintf(stderr, " NSMatrix: selectTextAtRow --- "); if (![selectedCell isEditable]) return; - [self lockFocus]; - // If RETURN key then make the next text the first responder if (key_code == 0x0d) { [selectedCell endEditing: nil]; [selectedCell drawInteriorWithFrame: rect inView: self]; - [self unlockFocus]; return; } @@ -2067,7 +2059,6 @@ fprintf(stderr, " NSMatrix: selectTextAtRow --- "); [selectedCell _handleKeyEvent: theEvent]; [selectedCell drawInteriorWithFrame: rect inView: self]; - [self unlockFocus]; } - (BOOL) acceptsFirstResponder diff --git a/Source/NSMenuItemCell.m b/Source/NSMenuItemCell.m index 15beb6c7a..cc0784d52 100644 --- a/Source/NSMenuItemCell.m +++ b/Source/NSMenuItemCell.m @@ -252,11 +252,13 @@ static BOOL usesUserKeyEquivalents = YES; - (void) drawWithFrame: (NSRect)cellFrame inView: (NSView *)controlView { - NSGraphicsContext *ctxt = GSCurrentContext(); + NSGraphicsContext *ctxt; NSRect floodRect = cellFrame; NSString *keyQ = nil; NSColor *backColor; + [controlView lockFocus]; + ctxt = GSCurrentContext(); NSDrawButton(cellFrame, cellFrame); floodRect.origin.x += 1; @@ -326,5 +328,6 @@ static BOOL usesUserKeyEquivalents = YES; [self _drawText:keyQ inFrame:floodRect]; } + [controlView unlockFocus]; } @end diff --git a/Source/NSPopUpButtonCell.m b/Source/NSPopUpButtonCell.m index 82b867a20..9c051538e 100644 --- a/Source/NSPopUpButtonCell.m +++ b/Source/NSPopUpButtonCell.m @@ -59,13 +59,15 @@ - (void) drawWithFrame: (NSRect)cellFrame inView: (NSView*)view { - NSGraphicsContext *ctxt = GSCurrentContext(); + NSGraphicsContext *ctxt; NSColor *backColor; NSImage *toDraw = nil; NSRect rect = cellFrame; NSRect arect = cellFrame; NSPoint point; + [view lockFocus]; + ctxt = GSCurrentContext(); NSDrawButton(cellFrame, cellFrame); arect.size.width -= 3; @@ -188,5 +190,6 @@ position.y += size.height; [toDraw compositeToPoint: position operation: NSCompositeCopy]; } + [view unlockFocus]; } @end diff --git a/Source/NSSliderCell.m b/Source/NSSliderCell.m index eb2d7af08..a59ad05e8 100644 --- a/Source/NSSliderCell.m +++ b/Source/NSSliderCell.m @@ -125,6 +125,7 @@ NSImage* image; NSSize size; + [controlView lockFocus]; if (vertical != _isVertical) { if (vertical) { image = [NSImage imageNamed: @"common_SliderVert"]; @@ -148,6 +149,7 @@ [self drawBarInside: cellFrame flipped: [controlView isFlipped]]; [self drawKnob]; + [controlView unlockFocus]; } - (float) knobThickness diff --git a/Source/NSTableHeaderCell.m b/Source/NSTableHeaderCell.m index 946b0505a..f9fa872be 100644 --- a/Source/NSTableHeaderCell.m +++ b/Source/NSTableHeaderCell.m @@ -5,8 +5,10 @@ - (void) drawInteriorWithFrame: (NSRect)cellFrame inView: (NSView *)controlView { + [controlView lockFocus]; [[NSColor controlShadowColor] set]; NSRectFill(cellFrame); [super drawInteriorWithFrame: cellFrame inView: controlView]; + [controlView unlockFocus]; } @end diff --git a/Source/NSTextFieldCell.m b/Source/NSTextFieldCell.m index 04b938b10..46eca3438 100644 --- a/Source/NSTextFieldCell.m +++ b/Source/NSTextFieldCell.m @@ -195,8 +195,10 @@ { if (draw_background) { + [controlView lockFocus]; [background_color set]; NSRectFill ([self drawingRectForBounds: cellFrame]); + [controlView unlockFocus]; } [super drawInteriorWithFrame: cellFrame inView: controlView]; }