mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 13:10:59 +00:00
Lock focus fixes - get cells to lock focus before drawing themselves.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@4924 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
8171e4cc22
commit
dd34792910
13 changed files with 85 additions and 25 deletions
37
ChangeLog
37
ChangeLog
|
@ -1,3 +1,40 @@
|
|||
Tue Sep 15 1999 Nicola Pero <n.pero@mi.flashnet.it>
|
||||
|
||||
(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 <n.pero@mi.flashnet.it>
|
||||
|
||||
* Source/NSView.m ([-setFrameSize:]): use zero width or height if
|
||||
|
|
|
@ -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];
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -304,9 +304,7 @@ id _nsbuttonCellClass = nil;
|
|||
|
||||
- (void) performClick: (id)sender
|
||||
{
|
||||
[self lockFocus];
|
||||
[cell performClick: sender];
|
||||
[self unlockFocus];
|
||||
}
|
||||
|
||||
- (BOOL) performKeyEquivalent: (NSEvent *)anEvent
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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:");
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -195,8 +195,10 @@
|
|||
{
|
||||
if (draw_background)
|
||||
{
|
||||
[controlView lockFocus];
|
||||
[background_color set];
|
||||
NSRectFill ([self drawingRectForBounds: cellFrame]);
|
||||
[controlView unlockFocus];
|
||||
}
|
||||
[super drawInteriorWithFrame: cellFrame inView: controlView];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue