GETWINDOW( xmotion ); GETMOUSE( xmotion );
/*
- * Set the current window
+ * Fallback if there's an active menu hooked to this window
*/
- fgStructure.Window = window ;
+ if( window->ActiveMenu != NULL )
+ {
+ /*
+ * Let's make the window redraw as a result of the mouse motion.
+ */
+ window->State.Redisplay = TRUE ;
+
+ break;
+ }
/*
* What kind of a movement was it?
if( window->Callbacks.Motion != NULL )
{
/*
+ * Set the current window
+ */
+ fgStructure.Window = window ;
+
+ /*
* Yup. Have it executed immediately
*/
window->Callbacks.Motion( event.xmotion.x, event.xmotion.y );
if( window->Callbacks.Passive != NULL )
{
/*
+ * Set the current window
+ */
+ fgStructure.Window = window ;
+
+ /*
* That's right, and there is a passive callback, too.
*/
window->Callbacks.Passive( event.xmotion.x, event.xmotion.y );
/* Execute the menu callback */
fgExecuteMenuCallback ( window->ActiveMenu ) ;
- fgDeactivateMenu ( window ) ;
+ fgDeactivateMenu ( window->ActiveMenu->ParentWindow ) ;
/* Restore the current window and menu */
fgSetWindow ( save_window ) ;
}
else /* Outside the menu, deactivate the menu if it's a downclick */
{
- if ( pressed == TRUE ) fgDeactivateMenu ( window ) ;
+ if ( pressed == TRUE ) fgDeactivateMenu ( window->ActiveMenu->ParentWindow ) ;
}
/*
window->State.Redisplay = TRUE ;
/*
+ * Set the current window
+ */
+ fgSetWindow( window );
+
+ /*
* Activate the appropriate menu structure...
*/
fgActivateMenu( window, button );
/*
* Check if there is a mouse callback hooked to the window
*/
- if( window->Callbacks.Mouse == NULL )
+ if( fgStructure.Window->Callbacks.Mouse == NULL )
break;
-
/*
* Set the current window
*/
- fgSetWindow( window );
+ fgSetWindow ( window );
+
/*
* Remember the current modifiers state
modifiers |= GLUT_ACTIVE_CTRL;
if (event.xbutton.state & Mod1Mask)
modifiers |= GLUT_ACTIVE_ALT;
- window->State.Modifiers = modifiers;
+ fgStructure.Window->State.Modifiers = modifiers;
/*
* Finally execute the mouse callback
*/
- window->Callbacks.Mouse(
+ fgStructure.Window->Callbacks.Mouse(
button,
event.type == ButtonPress ? GLUT_DOWN : GLUT_UP,
event.xbutton.x,
/*
* Trash the modifiers state
*/
- window->State.Modifiers = 0xffffffff;
+ fgStructure.Window->State.Modifiers = 0xffffffff;
}
break;
window->Window.Device = GetDC( hWnd );
/*
- * Setup the pixel format of our window
- */
- fgSetupPixelFormat( window, FALSE, PFD_MAIN_PLANE );
-
- /*
* Create or get the OpenGL rendering context now
*/
- if ( fgState.UseCurrentContext == TRUE )
- window->Window.Context = wglGetCurrentContext();
- else
+ if ( fgState.BuildingAMenu )
+ {
+ /*
+ * Setup the pixel format of our window
+ */
+ unsigned int current_DisplayMode = fgState.DisplayMode ;
+ fgState.DisplayMode = GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH ;
+ fgSetupPixelFormat( window, FALSE, PFD_MAIN_PLANE );
+ fgState.DisplayMode = current_DisplayMode ;
+
+ /*
+ * If there isn't already an OpenGL rendering context for menu windows, make one
+ */
+ if ( !fgStructure.MenuContext )
+ {
+ fgStructure.MenuContext = (SFG_MenuContext *)malloc ( sizeof(SFG_MenuContext) ) ;
+ fgStructure.MenuContext->Context = wglCreateContext( window->Window.Device );
+ }
+ else
+ wglMakeCurrent ( window->Window.Device, fgStructure.MenuContext->Context ) ;
+
+/* window->Window.Context = wglGetCurrentContext () ; */
window->Window.Context = wglCreateContext( window->Window.Device );
+ }
+ else
+ {
+ /*
+ * Setup the pixel format of our window
+ */
+ fgSetupPixelFormat( window, FALSE, PFD_MAIN_PLANE );
+
+ if ( fgState.UseCurrentContext == TRUE )
+ {
+ window->Window.Context = wglGetCurrentContext();
+ if ( ! window->Window.Context )
+ window->Window.Context = wglCreateContext( window->Window.Device );
+ }
+ else
+ window->Window.Context = wglCreateContext( window->Window.Device );
+ }
/*
* Still, we'll be needing to explicitly resize the window
/* Execute the menu callback */
fgExecuteMenuCallback ( window->ActiveMenu ) ;
- fgDeactivateMenu ( window ) ;
+ fgDeactivateMenu ( window->ActiveMenu->ParentWindow ) ;
/* Restore the current window and menu */
fgSetWindow ( save_window ) ;
}
else /* Outside the menu, deactivate the menu if it's a downclick */
{
- if ( pressed == TRUE ) fgDeactivateMenu ( window ) ;
+ if ( pressed == TRUE ) fgDeactivateMenu ( window->ActiveMenu->ParentWindow ) ;
}
/*
* Let's make the window redraw as a result of the mouse click and menu activity.
*/
- window->State.Redisplay = TRUE ;
+ if ( ! window->IsMenu ) window->State.Redisplay = TRUE ;
break ;
}
window->State.Redisplay = TRUE ;
/*
+ * Set the current window
+ */
+ fgSetWindow( window );
+
+ /*
* Activate the appropriate menu structure...
*/
fgActivateMenu( window, button );
/*
* Check if there is a mouse callback hooked to the window
*/
- if( window->Callbacks.Mouse == NULL )
+ if( fgStructure.Window->Callbacks.Mouse == NULL )
break;
/*
- * Set the current window
- */
- fgSetWindow( window );
-
- /*
* Remember the current modifiers state.
*/
- window->State.Modifiers =
+ fgStructure.Window->State.Modifiers =
( ( (GetKeyState( VK_LSHIFT ) < 0 ) || ( GetKeyState( VK_RSHIFT ) < 0 )) ? GLUT_ACTIVE_SHIFT : 0 ) |
( ( (GetKeyState( VK_LCONTROL ) < 0 ) || ( GetKeyState( VK_RCONTROL ) < 0 )) ? GLUT_ACTIVE_CTRL : 0 ) |
( ( (GetKeyState( VK_LMENU ) < 0 ) || ( GetKeyState( VK_RMENU ) < 0 )) ? GLUT_ACTIVE_ALT : 0 );
/*
+ * Set the current window
+ */
+ fgSetWindow ( window );
+
+ /*
* Finally execute the mouse callback
*/
- window->Callbacks.Mouse(
+ fgStructure.Window->Callbacks.Mouse(
button,
pressed == TRUE ? GLUT_DOWN : GLUT_UP,
window->State.MouseX,
/*
* Trash the modifiers state
*/
- window->State.Modifiers = 0xffffffff;
+ fgStructure.Window->State.Modifiers = 0xffffffff;
}
break;