X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Ffreeglut_menu.c;h=87e476ff20610d90f318fc45836d6b69b128476b;hb=b72d1f6bb74b866475328dd4fcfca8938c3e1317;hp=00e415d75ffc01e7ac84073f5f19f70b46f8c853;hpb=fe89df7de1aa6a732a441e983cce03e1fd6fd81a;p=freeglut diff --git a/src/freeglut_menu.c b/src/freeglut_menu.c index 00e415d..87e476f 100644 --- a/src/freeglut_menu.c +++ b/src/freeglut_menu.c @@ -62,7 +62,7 @@ static SFG_MenuEntry *fghFindMenuEntry( SFG_Menu* menu, int index ) SFG_MenuEntry *entry; int i = 1; - for( entry = menu->Entries.First; entry; entry = entry->Node.Next) + for( entry = (SFG_MenuEntry *)menu->Entries.First; entry; entry = (SFG_MenuEntry *)entry->Node.Next) { if (i == index) break; @@ -83,8 +83,8 @@ static GLboolean fghCheckMenuStatus( SFG_Window* window, SFG_Menu* menu ) /* * First of all check any of the active sub menus... */ - for( menuEntry = menu->Entries.First; menuEntry; - menuEntry = menuEntry->Node.Next ) + for( menuEntry = (SFG_MenuEntry *)menu->Entries.First; menuEntry; + menuEntry = (SFG_MenuEntry *)menuEntry->Node.Next ) { /* * Is that an active sub menu by any case? @@ -117,8 +117,8 @@ static GLboolean fghCheckMenuStatus( SFG_Window* window, SFG_Menu* menu ) /* * Mark all menu entries inactive... */ - for( menuEntry = menu->Entries.First; menuEntry; - menuEntry = menuEntry->Node.Next ) + for( menuEntry = (SFG_MenuEntry *)menu->Entries.First; menuEntry; + menuEntry = (SFG_MenuEntry *)menuEntry->Node.Next ) { menuEntry->IsActive = FALSE; } @@ -193,9 +193,10 @@ static GLboolean fghCheckMenuStatus( SFG_Window* window, SFG_Menu* menu ) menuEntry->SubMenu->Y = menu->Y + menuEntry->Ordinal * FREEGLUT_MENU_HEIGHT ; fgSetWindow ( menuEntry->SubMenu->Window ) ; - glutShowWindow () ; glutPositionWindow ( menuEntry->SubMenu->X, menuEntry->SubMenu->Y ) ; glutReshapeWindow ( menuEntry->SubMenu->Width, menuEntry->SubMenu->Height ) ; + glutPopWindow () ; + glutShowWindow () ; menuEntry->SubMenu->Window->ActiveMenu = menuEntry->SubMenu ; fgSetWindow ( current_window ) ; } @@ -254,8 +255,8 @@ static void fghDisplayMenuBox( SFG_Menu* menu ) /* * Check if any of the submenus is currently active... */ - for( menuEntry = menu->Entries.First; menuEntry; - menuEntry = menuEntry->Node.Next ) + for( menuEntry = (SFG_MenuEntry *)menu->Entries.First; menuEntry; + menuEntry = (SFG_MenuEntry *)menuEntry->Node.Next ) { /* * Has the menu been marked as active, maybe? @@ -287,8 +288,8 @@ static void fghDisplayMenuBox( SFG_Menu* menu ) */ glColor4f( 1, 1, 1, 1 ); - for( menuEntry = menu->Entries.First, i=0; menuEntry; - menuEntry = menuEntry->Node.Next, ++i ) + for( menuEntry = (SFG_MenuEntry *)menu->Entries.First, i=0; menuEntry; + menuEntry = (SFG_MenuEntry *)menuEntry->Node.Next, ++i ) { /* * Move the raster into position... @@ -333,8 +334,8 @@ static void fghDisplayMenuBox( SFG_Menu* menu ) /* * Now we are ready to check if any of our children needs to be redrawn: */ - for( menuEntry = menu->Entries.First; menuEntry; - menuEntry = menuEntry->Node.Next ) + for( menuEntry = (SFG_MenuEntry *)menu->Entries.First; menuEntry; + menuEntry = (SFG_MenuEntry *)menuEntry->Node.Next ) { /* * Is that an active sub menu by any case? @@ -360,7 +361,7 @@ static void fghSetSubmenuParentWindow ( SFG_Window *window, SFG_Menu *menu ) menu->ParentWindow = window ; - for ( menuEntry = menu->Entries.First; menuEntry; menuEntry = menuEntry->Node.Next ) + for ( menuEntry = (SFG_MenuEntry *)menu->Entries.First; menuEntry; menuEntry = (SFG_MenuEntry *)menuEntry->Node.Next ) { if ( menuEntry->SubMenu != NULL ) fghSetSubmenuParentWindow ( window, menuEntry->SubMenu ) ; @@ -465,6 +466,7 @@ void fgActivateMenu( SFG_Window* window, int button ) */ window->ActiveMenu = menu; menu->IsActive = TRUE ; + fgState.ActiveMenus ++ ; /* * Set up the initial menu position now: @@ -474,9 +476,10 @@ void fgActivateMenu( SFG_Window* window, int button ) menu->Y = window->State.MouseY + glutGet ( GLUT_WINDOW_Y ) ; fgSetWindow ( menu->Window ) ; - glutShowWindow () ; glutPositionWindow ( menu->X, menu->Y ) ; glutReshapeWindow ( menu->Width, menu->Height ) ; + glutPopWindow () ; + glutShowWindow () ; menu->Window->ActiveMenu = menu ; /* if( x > ( glutGet( GLUT_WINDOW_WIDTH ) - menu->Width ) ) @@ -511,7 +514,7 @@ void fgExecuteMenuCallback( SFG_Menu* menu ) /* * First of all check any of the active sub menus... */ - for( menuEntry = menu->Entries.First; menuEntry; menuEntry = menuEntry->Node.Next) + for( menuEntry = (SFG_MenuEntry *)menu->Entries.First; menuEntry; menuEntry = (SFG_MenuEntry *)menuEntry->Node.Next) { /* * Is this menu entry active? @@ -576,11 +579,13 @@ void fgDeactivateMenu( SFG_Window *window ) menu->ParentWindow->ActiveMenu = NULL ; menu->IsActive = FALSE ; + fgState.ActiveMenus -- ; + /* * Hide all submenu windows, and the root menu's window. */ - for ( menuEntry = menu->Entries.First; menuEntry; - menuEntry = menuEntry->Node.Next ) + for ( menuEntry = (SFG_MenuEntry *)menu->Entries.First; menuEntry; + menuEntry = (SFG_MenuEntry *)menuEntry->Node.Next ) { /* * Is that an active submenu by any case? @@ -589,7 +594,7 @@ void fgDeactivateMenu( SFG_Window *window ) fgDeactivateSubMenu ( menuEntry ) ; } - fgStructure.Window = current_window ; + fgSetWindow ( current_window ) ; } /* @@ -614,8 +619,8 @@ void fgDeactivateSubMenu( SFG_MenuEntry *menuEntry ) /* * Hide all submenu windows, and the root menu's window. */ - for ( subMenuIter = menuEntry->SubMenu->Entries.First; subMenuIter; - subMenuIter = subMenuIter->Node.Next ) + for ( subMenuIter = (SFG_MenuEntry *)menuEntry->SubMenu->Entries.First; subMenuIter; + subMenuIter = (SFG_MenuEntry *)subMenuIter->Node.Next ) { /* * Is that an active submenu by any case? @@ -624,7 +629,7 @@ void fgDeactivateSubMenu( SFG_MenuEntry *menuEntry ) fgDeactivateSubMenu ( subMenuIter ) ; } - fgStructure.Window = current_window ; + fgSetWindow ( current_window ) ; } /* @@ -643,8 +648,8 @@ void fghCalculateMenuBoxSize( void ) /* * The menu's box size depends on the menu entries: */ - for( menuEntry = fgStructure.Menu->Entries.First; menuEntry; - menuEntry = menuEntry->Node.Next) + for( menuEntry = (SFG_MenuEntry *)fgStructure.Menu->Entries.First; menuEntry; + menuEntry = (SFG_MenuEntry *)menuEntry->Node.Next) { /* * Update the menu entry's width value @@ -747,7 +752,7 @@ void FGAPIENTRY glutSetMenu( int menuID ) */ void FGAPIENTRY glutAddMenuEntry( const char* label, int value ) { - SFG_MenuEntry* menuEntry = calloc( sizeof(SFG_MenuEntry), 1 ); + SFG_MenuEntry* menuEntry = (SFG_MenuEntry *)calloc( sizeof(SFG_MenuEntry), 1 ); /* * Make sure there is a current menu set @@ -776,7 +781,7 @@ void FGAPIENTRY glutAddMenuEntry( const char* label, int value ) */ void FGAPIENTRY glutAddSubMenu( const char* label, int subMenuID ) { - SFG_MenuEntry* menuEntry = calloc( sizeof(SFG_MenuEntry), 1 ); + SFG_MenuEntry* menuEntry = (SFG_MenuEntry *)calloc( sizeof(SFG_MenuEntry), 1 ); SFG_Menu* subMenu = fgMenuByID( subMenuID ); /*