projects
/
freeglut
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Several updates from John and myself.
[freeglut]
/
src
/
freeglut_structure.c
diff --git
a/src/freeglut_structure.c
b/src/freeglut_structure.c
index
9945e99
..
09ad74d
100644
(file)
--- a/
src/freeglut_structure.c
+++ b/
src/freeglut_structure.c
@@
-65,7
+65,7
@@
SFG_Window* fgCreateWindow( SFG_Window* parent, const char* title, int x, int y,
/*
* Have the window object created
*/
/*
* Have the window object created
*/
- SFG_Window* window = calloc( sizeof(SFG_Window), 1 );
+ SFG_Window *window = (SFG_Window *)calloc( sizeof(SFG_Window), 1 );
int fakeArgc = 0;
/*
int fakeArgc = 0;
/*
@@
-138,7
+138,7
@@
SFG_Menu* fgCreateMenu( FGCBmenu menuCallback )
/*
* Have the menu object created
*/
/*
* Have the menu object created
*/
- SFG_Menu* menu = calloc( sizeof(SFG_Menu), 1 );
+ SFG_Menu* menu = (SFG_Menu *)calloc( sizeof(SFG_Menu), 1 );
int fakeArgc = 0;
/*
int fakeArgc = 0;
/*
@@
-168,7
+168,7
@@
SFG_Menu* fgCreateMenu( FGCBmenu menuCallback )
fgState.BuildingAMenu = FALSE ;
glutHideWindow () ; /* Hide the window for now */
fgState.BuildingAMenu = FALSE ;
glutHideWindow () ; /* Hide the window for now */
- fgStructure.Window = current_window ;
+ fgSetWindow ( current_window ) ;
/*
* Initialize the object properties:
/*
* Initialize the object properties:
@@
-273,6
+273,7
@@
void fgCloseWindows ()
void fgDestroyWindow( SFG_Window* window, GLboolean needToClose )
{
SFG_Window* subWindow;
void fgDestroyWindow( SFG_Window* window, GLboolean needToClose )
{
SFG_Window* subWindow;
+ int menu_index ;
assert( window != NULL );
freeglut_assert_ready;
assert( window != NULL );
freeglut_assert_ready;
@@
-280,7
+281,7
@@
void fgDestroyWindow( SFG_Window* window, GLboolean needToClose )
/*
* Does this window have any subwindows?
*/
/*
* Does this window have any subwindows?
*/
- while ( (subWindow = window->Children.First) != NULL )
+ while ( (subWindow = (SFG_Window *)window->Children.First) != NULL )
{
/*
* Destroy the first window in the list (possibly destroying
{
/*
* Destroy the first window in the list (possibly destroying
@@
-296,9
+297,9
@@
void fgDestroyWindow( SFG_Window* window, GLboolean needToClose )
if ( window->Callbacks.Destroy != NULL )
{
SFG_Window *activeWindow = fgStructure.Window ;
if ( window->Callbacks.Destroy != NULL )
{
SFG_Window *activeWindow = fgStructure.Window ;
- fgStructure.Window = window ;
+ fgSetWindow ( window ) ;
window->Callbacks.Destroy () ;
window->Callbacks.Destroy () ;
- fgStructure.Window = activeWindow ;
+ fgSetWindow ( activeWindow ) ;
}
/*
}
/*
@@
-309,6
+310,15
@@
void fgDestroyWindow( SFG_Window* window, GLboolean needToClose )
else
fgListRemove( &fgStructure.Windows, &window->Node );
else
fgListRemove( &fgStructure.Windows, &window->Node );
+ if ( window->ActiveMenu != NULL )
+ fgDeactivateMenu ( window ) ;
+
+ for ( menu_index = 0; menu_index < 3; menu_index ++ )
+ {
+ if ( window->Menu[menu_index] != NULL )
+ window->Menu[menu_index]->ParentWindow = NULL ;
+ }
+
/*
* OK, this window seems disconnected from the structure enough
* in order to be closed without any bigger risks...
/*
* OK, this window seems disconnected from the structure enough
* in order to be closed without any bigger risks...
@@
-321,6
+331,7
@@
void fgDestroyWindow( SFG_Window* window, GLboolean needToClose )
* have everything inside it freed and we do not have to care...
*/
free( window );
* have everything inside it freed and we do not have to care...
*/
free( window );
+ if ( fgStructure.Window == window ) fgStructure.Window = NULL ;
}
/*
}
/*
@@
-345,8
+356,8
@@
static void fghRemoveMenuFromWindow( SFG_Window* window, SFG_Menu* menu )
/*
* Call this function for all of the window's children recursively:
*/
/*
* Call this function for all of the window's children recursively:
*/
- for( subWindow = window->Children.First; subWindow;
- subWindow = subWindow->Node.Next)
+ for( subWindow = (SFG_Window *)window->Children.First; subWindow;
+ subWindow = (SFG_Window *)subWindow->Node.Next)
{
fghRemoveMenuFromWindow( subWindow, menu );
}
{
fghRemoveMenuFromWindow( subWindow, menu );
}
@@
-360,7
+371,7
@@
static void fghRemoveMenuFromMenu( SFG_Menu* from, SFG_Menu* menu )
{
SFG_MenuEntry *entry;
{
SFG_MenuEntry *entry;
- for( entry = from->Entries.First; entry; entry = entry->Node.Next )
+ for( entry = (SFG_MenuEntry *)from->Entries.First; entry; entry = (SFG_MenuEntry *)entry->Node.Next )
{
if (entry->SubMenu == menu)
{
{
if (entry->SubMenu == menu)
{
@@
-385,7
+396,7
@@
void fgDestroyMenu( SFG_Menu* menu )
/*
* First of all, have all references to this menu removed from all windows:
*/
/*
* First of all, have all references to this menu removed from all windows:
*/
- for( window = fgStructure.Windows.First; window; window = window->Node.Next )
+ for( window = (SFG_Window *)fgStructure.Windows.First; window; window = (SFG_Window *)window->Node.Next )
{
fghRemoveMenuFromWindow( window, menu );
}
{
fghRemoveMenuFromWindow( window, menu );
}
@@
-393,7
+404,7
@@
void fgDestroyMenu( SFG_Menu* menu )
/*
* Now proceed with removing menu entries that lead to this menu
*/
/*
* Now proceed with removing menu entries that lead to this menu
*/
- for( from = fgStructure.Menus.First; from; from = from->Node.Next )
+ for( from = (SFG_Menu *)fgStructure.Menus.First; from; from = (SFG_Menu *)from->Node.Next )
{
fghRemoveMenuFromMenu( from, menu );
}
{
fghRemoveMenuFromMenu( from, menu );
}
@@
-414,7
+425,7
@@
void fgDestroyMenu( SFG_Menu* menu )
* Now we are pretty sure the menu is not used anywhere
* and that we can remove all of its entries
*/
* Now we are pretty sure the menu is not used anywhere
* and that we can remove all of its entries
*/
- while( (entry = menu->Entries.First) != NULL )
+ while( (entry = (SFG_MenuEntry *)menu->Entries.First) != NULL )
{
fgListRemove(&menu->Entries, &entry->Node);
{
fgListRemove(&menu->Entries, &entry->Node);
@@
-432,6
+443,9
@@
void fgDestroyMenu( SFG_Menu* menu )
/*
* Destroy the window associated with the menu
*/
/*
* Destroy the window associated with the menu
*/
+ if ( fgStructure.Window == menu->Window )
+ fgSetWindow ( menu->ParentWindow ) ;
+
fgDestroyWindow ( menu->Window, TRUE ) ;
/*
fgDestroyWindow ( menu->Window, TRUE ) ;
/*
@@
-486,11
+500,11
@@
void fgDestroyStructure( void )
/*
* Make sure all windows and menus have been deallocated
*/
/*
* Make sure all windows and menus have been deallocated
*/
- while( (window = fgStructure.Windows.First) != NULL )
- fgDestroyWindow( window, TRUE );
-
- while( (menu = fgStructure.Menus.First) != NULL )
+ while( (menu = (SFG_Menu *)fgStructure.Menus.First) != NULL )
fgDestroyMenu( menu );
fgDestroyMenu( menu );
+
+ while( (window = (SFG_Window *)fgStructure.Windows.First) != NULL )
+ fgDestroyWindow( window, TRUE );
}
/*
}
/*
@@
-506,8
+520,8
@@
void fgEnumWindows( FGCBenumerator enumCallback, SFG_Enumerator* enumerator )
/*
* Check every of the top-level windows
*/
/*
* Check every of the top-level windows
*/
- for( window = fgStructure.Windows.First; window;
- window = window->Node.Next )
+ for( window = (SFG_Window *)fgStructure.Windows.First; window;
+ window = (SFG_Window *)window->Node.Next )
{
/*
* Execute the callback...
{
/*
* Execute the callback...
@@
-535,7
+549,7
@@
void fgEnumSubWindows( SFG_Window* window, FGCBenumerator enumCallback, SFG_Enum
/*
* Check every of the window's children:
*/
/*
* Check every of the window's children:
*/
- for( child = window->Children.First; child; child = child->Node.Next )
+ for( child = (SFG_Window *)window->Children.First; child; child = (SFG_Window *)child->Node.Next )
{
/*
* Execute the callback...
{
/*
* Execute the callback...
@@
-694,7
+708,7
@@
SFG_Menu* fgMenuByID( int menuID )
/*
* It's enough to check all entries in fgStructure.Menus...
*/
/*
* It's enough to check all entries in fgStructure.Menus...
*/
- for( menu = fgStructure.Menus.First; menu; menu = menu->Node.Next )
+ for( menu = (SFG_Menu *)fgStructure.Menus.First; menu; menu = (SFG_Menu *)menu->Node.Next )
{
/*
* Does the ID number match?
{
/*
* Does the ID number match?
@@
-722,7
+736,7
@@
void fgListAppend(SFG_List *list, SFG_Node *node)
{
SFG_Node *ln;
{
SFG_Node *ln;
- if ( (ln = list->Last) != NULL )
+ if ( (ln = (SFG_Node *)list->Last) != NULL )
{
ln->Next = node;
node->Prev = ln;
{
ln->Next = node;
node->Prev = ln;
@@
-741,13
+755,13
@@
void fgListRemove(SFG_List *list, SFG_Node *node)
{
SFG_Node *ln;
{
SFG_Node *ln;
- if ( (ln = node->Next) != NULL )
+ if ( (ln = (SFG_Node *)node->Next) != NULL )
ln->Prev = node->Prev;
ln->Prev = node->Prev;
- if ( (ln = node->Prev) != NULL )
+ if ( (ln = (SFG_Node *)node->Prev) != NULL )
ln->Next = node->Next;
ln->Next = node->Next;
- if ( (ln = list->First) == node )
+ if ( (ln = (SFG_Node *)list->First) == node )
list->First = node->Next;
list->First = node->Next;
- if ( (ln = list->Last) == node )
+ if ( (ln = (SFG_Node *)list->Last) == node )
list->Last = node->Prev;
}
list->Last = node->Prev;
}
@@
-756,7
+770,7
@@
int fgListLength(SFG_List *list)
SFG_Node *node;
int length = 0;
SFG_Node *node;
int length = 0;
- for( node = list->First; node; node = node->Next )
+ for( node = (SFG_Node *)list->First; node; node = (SFG_Node *)node->Next )
++length;
return( length );
++length;
return( length );