glutDialsFunc ( Dials ) ;
glutTabletMotionFunc ( TabletMotion ) ;
glutTabletButtonFunc ( TabletButton ) ;
- glutMenuDestroyFunc ( MenuDestroy );
glutMenuStatusFunc ( MenuStatus );
glutSetKeyRepeat(GLUT_KEY_REPEAT_OFF) ;
glutAddMenuEntry( "Sub menu A1 (01)", 1 );
glutAddMenuEntry( "Sub menu A2 (02)", 2 );
glutAddMenuEntry( "Sub menu A3 (03)", 3 );
+ glutMenuDestroyFunc ( MenuDestroy );
subMenuB = glutCreateMenu( MenuCallback );
glutAddMenuEntry( "Sub menu B1 (04)", 4 );
glutAddMenuEntry( "Sub menu B2 (05)", 5 );
glutAddMenuEntry( "Sub menu B3 (06)", 6 );
glutAddSubMenu( "Going to sub menu A", subMenuA );
+ glutMenuDestroyFunc ( MenuDestroy );
menuID = glutCreateMenu( MenuCallback );
glutAddMenuEntry( "Entry one", 1 );
glutAddMenuEntry( "Entry five", 5 );
glutAddSubMenu( "Enter sub menu A", subMenuA );
glutAddSubMenu( "Enter sub menu B", subMenuB );
+ glutMenuDestroyFunc ( MenuDestroy );
glutAttachMenu( GLUT_LEFT_BUTTON );
menu->Window->State.MouseY =
window->State.MouseY + glutGet( GLUT_WINDOW_Y ) - menu->Y;
+ /* Menu status callback */
+ printf("Menu status callback: %p\n",fgState.MenuStatusCallback);
+ if (fgState.MenuStateCallback || fgState.MenuStatusCallback)
+ {
+ fgStructure.CurrentMenu = menu;
+ fgStructure.CurrentWindow = window;
+ if (fgState.MenuStateCallback)
+ fgState.MenuStateCallback(GLUT_MENU_IN_USE);
+ if (fgState.MenuStatusCallback)
+ fgState.MenuStatusCallback(GLUT_MENU_IN_USE, window->State.MouseX, window->State.MouseY);
+ }
+
fgSetWindow( menu->Window );
glutPositionWindow( menu->X, menu->Y );
glutReshapeWindow( menu->Width, menu->Height );
}
fgSetWindow ( parent_window ) ;
+
+ /* Menu status callback */
+ if (fgState.MenuStateCallback || fgState.MenuStatusCallback)
+ {
+ fgStructure.CurrentMenu = menu;
+ fgStructure.CurrentWindow = parent_window;
+ if (fgState.MenuStateCallback)
+ fgState.MenuStateCallback(GLUT_MENU_NOT_IN_USE);
+ if (fgState.MenuStatusCallback)
+ {
+ /* Get cursor position on screen and convert to relative to parent_window's client area */
+ POINT mouse_pos;
+ GetCursorPos(&mouse_pos);
+ mouse_pos.x -= glutGet( GLUT_WINDOW_X );
+ mouse_pos.y -= glutGet( GLUT_WINDOW_Y );
+
+ fgState.MenuStatusCallback(GLUT_MENU_NOT_IN_USE, mouse_pos.x, mouse_pos.y);
+ }
+ }
}
/*
{
/* The menu object creation code resides in freeglut_structure.c */
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutCreateMenu" );
+ if (fgGetActiveMenu())
+ fgError("Menu manipulation not allowed while menus in use.");
+
return fgCreateMenu( callback )->ID;
}
menu = fgMenuByID( menuID );
freeglut_return_if_fail( menu );
+ if (fgGetActiveMenu())
+ fgError("Menu manipulation not allowed while menus in use.");
/* The menu object destruction code resides in freeglut_structure.c */
fgDestroyMenu( menu );
SFG_MenuEntry* menuEntry;
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutAddMenuEntry" );
menuEntry = (SFG_MenuEntry *)calloc( sizeof(SFG_MenuEntry), 1 );
+
freeglut_return_if_fail( fgStructure.CurrentMenu );
+ if (fgGetActiveMenu())
+ fgError("Menu manipulation not allowed while menus in use.");
menuEntry->Text = strdup( label );
menuEntry->ID = value;
subMenu = fgMenuByID( subMenuID );
freeglut_return_if_fail( fgStructure.CurrentMenu );
+ if (fgGetActiveMenu())
+ fgError("Menu manipulation not allowed while menus in use.");
+
freeglut_return_if_fail( subMenu );
menuEntry->Text = strdup( label );
SFG_MenuEntry* menuEntry = NULL;
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutChangeToMenuEntry" );
+
freeglut_return_if_fail( fgStructure.CurrentMenu );
+ if (fgGetActiveMenu())
+ fgError("Menu manipulation not allowed while menus in use.");
/* Get n-th menu entry in the current menu, starting from one: */
menuEntry = fghFindMenuEntry( fgStructure.CurrentMenu, item );
SFG_MenuEntry* menuEntry;
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutChangeToSubMenu" );
- subMenu = fgMenuByID( subMenuID );
- menuEntry = NULL;
freeglut_return_if_fail( fgStructure.CurrentMenu );
+ if (fgGetActiveMenu())
+ fgError("Menu manipulation not allowed while menus in use.");
+
+ /* Get handle to sub menu */
+ subMenu = fgMenuByID( subMenuID );
+ menuEntry = NULL;
freeglut_return_if_fail( subMenu );
/* Get n-th menu entry in the current menu, starting from one: */
SFG_MenuEntry* menuEntry;
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutRemoveMenuItem" );
+
freeglut_return_if_fail( fgStructure.CurrentMenu );
+ if (fgGetActiveMenu())
+ fgError("Menu manipulation not allowed while menus in use.");
/* Get n-th menu entry in the current menu, starting from one: */
menuEntry = fghFindMenuEntry( fgStructure.CurrentMenu, item );
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutAttachMenu" );
freeglut_return_if_fail( fgStructure.CurrentWindow );
+
freeglut_return_if_fail( fgStructure.CurrentMenu );
+ if (fgGetActiveMenu())
+ fgError("Menu manipulation not allowed while menus in use.");
freeglut_return_if_fail( button >= 0 );
freeglut_return_if_fail( button < FREEGLUT_MAX_MENUS );
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutDetachMenu" );
freeglut_return_if_fail( fgStructure.CurrentWindow );
+
freeglut_return_if_fail( fgStructure.CurrentMenu );
+ if (fgGetActiveMenu())
+ fgError("Menu manipulation not allowed while menus in use.");
freeglut_return_if_fail( button >= 0 );
freeglut_return_if_fail( button < FREEGLUT_MAX_MENUS );