More fixes.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@4628 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
michael 1999-07-20 10:34:34 +00:00
parent 3d22b9b098
commit 2e3c92ba3c
2 changed files with 63 additions and 5 deletions

View file

@ -6,6 +6,10 @@
setMenu:, that will make the code sharing between NSMenu and setMenu:, that will make the code sharing between NSMenu and
NSPopUp complete. NSPopUp complete.
Also documented the event code a little. Interestingly enough by
doing this I know what needs to be looked at better. Suprise,
suprise.
1999-07-19 Michael Hanni <mhanni@sprintmail.com> 1999-07-19 Michael Hanni <mhanni@sprintmail.com>
* Source/NSTableView.m: very incomplete implementation. * Source/NSTableView.m: very incomplete implementation.

View file

@ -522,17 +522,23 @@ static float GSMenuBarHeight = 25.0; // a guess.
case NSRightMouseDragged: case NSRightMouseDragged:
case NSLeftMouseDragged: case NSLeftMouseDragged:
lastLocation = [[self window] mouseLocationOutsideOfEventStream]; lastLocation = [[self window] mouseLocationOutsideOfEventStream];
lastLocation = [self convertPoint: lastLocation fromView: nil];
#if 0 #if 0
NSLog (@"location = (%f, %f, %f)", lastLocation.x, [[self window] NSLog (@"location = (%f, %f, %f)", lastLocation.x, [[self window]
frame].origin.x, [[self window] frame].size.width); frame].origin.x, [[self window] frame].size.width);
NSLog (@"location = %f (%f, %f)", lastLocation.y, [[self window]
frame].origin.y, [[self window] frame].size.height);
#endif #endif
/* If the location of the mouse is inside the window on the
x-axis. */
if (lastLocation.x > 0 if (lastLocation.x > 0
&& lastLocation.x < [[self window] frame].size.width) && lastLocation.x < [[self window] frame].size.width)
{ {
lastLocation = [self convertPoint: lastLocation
fromView: nil]; /* Get the index from some simple math. */
index = (height - lastLocation.y) / cellSize.height; index = (height - lastLocation.y) / cellSize.height;
#if 0 #if 0
@ -540,6 +546,8 @@ static float GSMenuBarHeight = 25.0; // a guess.
lastLocation.x, lastLocation.y); lastLocation.x, lastLocation.y);
NSLog (@"index = %d\n", index); NSLog (@"index = %d\n", index);
#endif #endif
/* If the index generated above is valid, use it. */
if (index >= 0 && index < theCount) if (index >= 0 && index < theCount)
{ {
if (index != lastIndex) if (index != lastIndex)
@ -557,7 +565,23 @@ static float GSMenuBarHeight = 25.0; // a guess.
} }
} }
} }
/* If we leave the bottom or top deselect menu items in
the current view. This should check to see if the
current item, if any, has an open submenu. */
if (lastLocation.y > [[self window] frame].size.height
|| lastLocation.y < 0)
{
[self setHighlightedItemIndex: -1];
}
} }
/* If the location of the mouse is greater than the width of
the current window we need to see if we should display a
submenu. */
else if (lastLocation.x > [[self window] frame].size.width) else if (lastLocation.x > [[self window] frame].size.width)
{ {
NSRect aRect = [self rectOfItemAtIndex: lastIndex]; NSRect aRect = [self rectOfItemAtIndex: lastIndex];
@ -577,6 +601,10 @@ static float GSMenuBarHeight = 25.0; // a guess.
[window flushWindow]; [window flushWindow];
} }
} }
/* If the mouse location is less than 0 we moved to the left,
perhaps into a supermenu? */
else if (lastLocation.x < 0) else if (lastLocation.x < 0)
{ {
if ([menuv_menu supermenu]) if ([menuv_menu supermenu])
@ -592,6 +620,7 @@ static float GSMenuBarHeight = 25.0; // a guess.
[window flushWindow]; [window flushWindow];
} }
} }
/* FIXME this code is just plain nasty.
else else
{ {
// FIXME, Michael. This might be needed... or not? // FIXME, Michael. This might be needed... or not?
@ -604,12 +633,17 @@ static float GSMenuBarHeight = 25.0; // a guess.
[window flushWindow]; [window flushWindow];
} }
} }
*/
[window flushWindow]; [window flushWindow];
default: default:
break; break;
} }
} }
/* If we didn't move out of the window to the left or right, and if we
didn't move beyond the bounds of the menu (?) and if we have a selected
cell do the following */
if (!weLeftMenu && !weRightMenu && !weWereOut if (!weLeftMenu && !weRightMenu && !weWereOut
&& menuv_highlightedItemIndex != -1) && menuv_highlightedItemIndex != -1)
{ {
@ -632,6 +666,8 @@ static float GSMenuBarHeight = 25.0; // a guess.
else if ([selectedCell action] && [selectedCell target]) else if ([selectedCell action] && [selectedCell target])
[menuv_popb performSelector:[selectedCell action] withObject:selectedCell]; [menuv_popb performSelector:[selectedCell action] withObject:selectedCell];
/* If we are a menu */
if (menuv_menu) if (menuv_menu)
{ {
while (!finished) while (!finished)
@ -659,7 +695,9 @@ static float GSMenuBarHeight = 25.0; // a guess.
[window flushWindow]; [window flushWindow];
} }
} }
/* If we are a popup */
if (menuv_popb) if (menuv_popb)
{ {
[menuv_popb close]; [menuv_popb close];
@ -667,6 +705,21 @@ static float GSMenuBarHeight = 25.0; // a guess.
} }
} }
/* If the mouse is released and there is no highlighted cell */
else if (menuv_highlightedItemIndex == -1)
{
NSLog(@"This is the popupbutton close if not selected test.\n");
if (menuv_popb)
{
[menuv_popb close];
}
}
/* We went to the left of the current NSMenuView. BOOL is a misnomer. */
else if (weRightMenu) else if (weRightMenu)
{ {
NSPoint cP = [[self window] convertBaseToScreen: lastLocation]; NSPoint cP = [[self window] convertBaseToScreen: lastLocation];
@ -698,12 +751,13 @@ static float GSMenuBarHeight = 25.0; // a guess.
pressure: [event pressure]]]; pressure: [event pressure]]];
} }
} }
/* We went to the right of the current NSMenuView. BOOL is a misnomer. */
else if (weLeftMenu) else if (weLeftMenu)
{ /* The weLeftMenu case */ { /* The weLeftMenu case */
NSPoint cP = [[self window] convertBaseToScreen: lastLocation]; NSPoint cP = [[self window] convertBaseToScreen: lastLocation];
NSLog(@"Urph.\n");
selectedCell = [menuv_items_link objectAtIndex: lastIndex]; selectedCell = [menuv_items_link objectAtIndex: lastIndex];
if ([selectedCell hasSubmenu]) if ([selectedCell hasSubmenu])
{ {