Made comboboxes work in flipped views.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@19541 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2004-06-18 00:01:18 +00:00
parent a9031e5bfc
commit 2ed0ec270e
2 changed files with 33 additions and 14 deletions

View file

@ -1,3 +1,11 @@
2004-06-17 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSComboBoxCell.m: buttonCellFrameFromRect(),
(-drawWithFrame:inView:), (-highlight:withFrame:inView:) and
(-trackMouse:...untilMouseUp:): Made draw bettere when used in a
flipped view. (-positionWithComboBoxCell:) position popup correctly
for flipped view.
2004-06-16 Fred Kiefer <FredKiefer@gmx.de> 2004-06-16 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSTableView.m: (-mouseDown:) Added mouse tracking in the cell. * Source/NSTableView.m: (-mouseDown:) Added mouse tracking in the cell.

View file

@ -308,7 +308,6 @@ static GSComboWindow *gsWindow = nil;
NSRect viewWithComboCellFrame; NSRect viewWithComboCellFrame;
NSRect rect; NSRect rect;
NSPoint point, oldPoint; NSPoint point, oldPoint;
NSView *superview = [viewWithComboCell superview];
[self layoutWithComboBoxCell: comboBoxCell]; [self layoutWithComboBoxCell: comboBoxCell];
@ -319,8 +318,16 @@ static GSComboWindow *gsWindow = nil;
screenFrame = [[[viewWithComboCell window] screen] frame]; screenFrame = [[[viewWithComboCell window] screen] frame];
viewWithComboCellFrame = [comboBoxCell _textCellFrame]; viewWithComboCellFrame = [comboBoxCell _textCellFrame];
point = viewWithComboCellFrame.origin; if ([viewWithComboCell isFlipped])
{
point = viewWithComboCellFrame.origin;
point.y = NSMaxY(viewWithComboCellFrame);
}
else
{
point = viewWithComboCellFrame.origin;
}
// Switch to the window coordinates // Switch to the window coordinates
point = [viewWithComboCell convertPoint: point toView: nil]; point = [viewWithComboCell convertPoint: point toView: nil];
@ -1319,7 +1326,7 @@ static inline NSRect textCellFrameFromRect(NSRect cellRect)
static inline NSRect buttonCellFrameFromRect(NSRect cellRect) static inline NSRect buttonCellFrameFromRect(NSRect cellRect)
{ {
return NSMakeRect(NSMaxX(cellRect) - ButtonWidth - BorderSize, return NSMakeRect(NSMaxX(cellRect) - ButtonWidth - BorderSize,
NSMaxY(cellRect) - ButtonHeight - BorderSize, NSMinY(cellRect) + BorderSize,
ButtonWidth, ButtonWidth,
ButtonHeight); ButtonHeight);
} }
@ -1338,7 +1345,8 @@ static inline NSRect buttonCellFrameFromRect(NSRect cellRect)
- (void) drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView - (void) drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
{ {
NSRect rect = NSMakeRect(cellFrame.origin.x, cellFrame.origin.y, cellFrame.size.width, ComboBoxHeight); // NSRect rect = NSMakeRect(cellFrame.origin.x, cellFrame.origin.y, cellFrame.size.width, ComboBoxHeight);
NSRect rect = cellFrame;
// FIX ME: Is this test case below with the method call really needed ? // FIX ME: Is this test case below with the method call really needed ?
if ([GSCurrentContext() isDrawingToScreen]) if ([GSCurrentContext() isDrawingToScreen])
@ -1360,8 +1368,9 @@ static inline NSRect buttonCellFrameFromRect(NSRect cellRect)
withFrame: (NSRect)cellFrame withFrame: (NSRect)cellFrame
inView: (NSView *)controlView inView: (NSView *)controlView
{ {
NSRect rect = NSMakeRect(cellFrame.origin.x, cellFrame.origin.y, cellFrame.size.width, ComboBoxHeight); // NSRect rect = NSMakeRect(cellFrame.origin.x, cellFrame.origin.y, cellFrame.size.width, ComboBoxHeight);
NSRect rect = cellFrame;
// FIX ME: Is this test case below with the method call really needed ? // FIX ME: Is this test case below with the method call really needed ?
if ([GSCurrentContext() isDrawingToScreen]) if ([GSCurrentContext() isDrawingToScreen])
{ {
@ -1387,7 +1396,8 @@ static inline NSRect buttonCellFrameFromRect(NSRect cellRect)
NSPoint point; NSPoint point;
BOOL isFlipped = [controlView isFlipped]; BOOL isFlipped = [controlView isFlipped];
BOOL clicked = NO; BOOL clicked = NO;
NSRect buttonRect = buttonCellFrameFromRect(cellFrame);
// Should this be set by NSActionCell ? // Should this be set by NSActionCell ?
if (_control_view != controlView) if (_control_view != controlView)
_control_view = controlView; _control_view = controlView;
@ -1405,22 +1415,22 @@ static inline NSRect buttonCellFrameFromRect(NSRect cellRect)
{ {
return NO; return NO;
} }
else if (NSMouseInRect(point, buttonCellFrameFromRect(cellFrame), isFlipped)) else if (NSMouseInRect(point, buttonRect, isFlipped))
{ {
[controlView lockFocus]; [controlView lockFocus];
[_buttonCell highlight: YES withFrame: buttonCellFrameFromRect(cellFrame) inView: controlView]; [_buttonCell highlight: YES withFrame: buttonRect inView: controlView];
[controlView unlockFocus]; [controlView unlockFocus];
[cvWindow flushWindow]; [cvWindow flushWindow];
clicked = [_buttonCell trackMouse: theEvent clicked = [_buttonCell trackMouse: theEvent
inRect: buttonCellFrameFromRect(cellFrame) inRect: buttonRect
ofView: controlView ofView: controlView
untilMouseUp: NO]; untilMouseUp: NO];
/* The click will be send by the target/action we have set for the button cell. */ /* The click will be send by the target/action we have set for the button cell. */
[controlView lockFocus]; [controlView lockFocus];
[_buttonCell highlight: NO withFrame: buttonCellFrameFromRect(cellFrame) inView: controlView]; [_buttonCell highlight: NO withFrame: buttonRect inView: controlView];
[controlView unlockFocus]; [controlView unlockFocus];
[cvWindow flushWindow]; [cvWindow flushWindow];
@ -1654,10 +1664,11 @@ static inline NSRect buttonCellFrameFromRect(NSRect cellRect)
inView: (NSView *)controlView inView: (NSView *)controlView
{ {
NSWindow *cvWindow = [controlView window]; NSWindow *cvWindow = [controlView window];
NSRect buttonRect = buttonCellFrameFromRect(cellFrame);
[controlView lockFocus]; [controlView lockFocus];
[_buttonCell highlight: YES [_buttonCell highlight: YES
withFrame: buttonCellFrameFromRect(cellFrame) withFrame: buttonRect
inView: controlView]; inView: controlView];
[controlView unlockFocus]; [controlView unlockFocus];
[cvWindow flushWindow]; [cvWindow flushWindow];
@ -1666,7 +1677,7 @@ static inline NSRect buttonCellFrameFromRect(NSRect cellRect)
[controlView lockFocus]; [controlView lockFocus];
[_buttonCell highlight: NO [_buttonCell highlight: NO
withFrame: buttonCellFrameFromRect(cellFrame) withFrame: buttonRect
inView: controlView]; inView: controlView];
[controlView unlockFocus]; [controlView unlockFocus];
[cvWindow flushWindow]; [cvWindow flushWindow];