/*
- * freeglut_structure.c
+ * fg_structure.c
*
* Windows and menus need tree structure
*
/* -- PRIVATE FUNCTIONS ---------------------------------------------------- */
extern void fgPlatformCreateWindow ( SFG_Window *window );
+extern void fghDefaultReshape(int width, int height);
static void fghClearCallBacks( SFG_Window *window )
{
GLboolean gameMode, GLboolean isMenu )
{
/* Have the window object created */
- SFG_Window *window = (SFG_Window *)calloc( sizeof(SFG_Window), 1 );
+ SFG_Window *window = (SFG_Window *)calloc( 1, sizeof(SFG_Window) );
fgPlatformCreateWindow ( window );
fghClearCallBacks( window );
+ SET_WCB( *window, Reshape, fghDefaultReshape);
/* Initialize the object properties */
window->ID = ++fgStructure.WindowID;
else
fgListAppend( &fgStructure.Windows, &window->Node );
- /* Set the default mouse cursor and reset the modifiers value */
+ /* Set the default mouse cursor */
window->State.Cursor = GLUT_CURSOR_INHERIT;
- window->IsMenu = isMenu;
-
- window->State.IgnoreKeyRepeat = GL_FALSE;
- window->State.KeyRepeating = GL_FALSE;
- window->State.IsFullscreen = GL_FALSE;
+ /* Mark window as menu if a menu is to be created */
+ window->IsMenu = isMenu;
/*
* Open the window now. The fgOpenWindow() function is system
- * dependant, and resides in freeglut_window.c. Uses fgState.
+ * dependant, and resides in fg_window.c. Uses fgState.
*/
fgOpenWindow( window, title, positionUse, x, y, sizeUse, w, h, gameMode,
(GLboolean)(parent ? GL_TRUE : GL_FALSE) );
*/
SFG_Menu* fgCreateMenu( FGCBMenu menuCallback )
{
- int x = 100, y = 100, w = 1, h = 1;
SFG_Window *current_window = fgStructure.CurrentWindow;
/* Have the menu object created */
menu->ParentWindow = NULL;
/* Create a window for the menu to reside in. */
-
- fgCreateWindow( NULL, "freeglut menu", GL_TRUE, x, y, GL_TRUE, w, h,
+ fgCreateWindow( NULL, "freeglut menu", GL_FALSE, 0, 0, GL_FALSE, 0, 0,
GL_FALSE, GL_TRUE );
menu->Window = fgStructure.CurrentWindow;
glutDisplayFunc( fgDisplayMenu );
- glutHideWindow( ); /* Hide the window for now */
fgSetWindow( current_window );
/* Initialize the object properties: */
menu->ID = ++fgStructure.MenuID;
menu->Callback = menuCallback;
menu->ActiveEntry = NULL;
+ menu->Font = fgState.MenuFont;
fgListInit( &menu->Entries );
fgListAppend( &fgStructure.Menus, &menu->Node );
/*
* This function destroys a window and all of its subwindows. Actually,
- * another function, defined in freeglut_window.c is called, but this is
+ * another function, defined in fg_window.c is called, but this is
* a whole different story...
*/
void fgDestroyWindow( SFG_Window* window )
/*
* fgWindowByHandle returns a (SFG_Window *) value pointing to the
* first window in the queue matching the specified window handle.
- * The function is defined in freeglut_structure.c file.
+ * The function is defined in fg_structure.c file.
*/
SFG_Window* fgWindowByHandle ( SFG_WindowHandleType hWindow )
{
/*
* This function is similar to the previous one, except it is
* looking for a specified (sub)window identifier. The function
- * is defined in freeglut_structure.c file.
+ * is defined in fg_structure.c file.
*/
SFG_Window* fgWindowByID( int windowID )
{
return;
/* Check the menu's ID. */
- if( menu->ID == (int)(enumerator->data) )
+ if( menu->ID == *( int *)(enumerator->data) )
{
enumerator->found = GL_TRUE;
enumerator->data = menu;
/* This is easy and makes use of the menus enumeration defined above */
enumerator.found = GL_FALSE;
- enumerator.data = (void *)menuID;
+ enumerator.data = (void *)&menuID;
fgEnumMenus( fghcbMenuByID, &enumerator );
if( enumerator.found )
if ( enumerator->found )
return;
- /* Check the menu's ID. */
+ /* Check the menu's is active */
if( menu->IsActive )
{
enumerator->found = GL_TRUE;
/*
* Returns active menu, if any. Assumption: only one menu active throughout application at any one time.
+ * This is false when a submenu is also open.
* This is easier than fgWindowByXXX as all menus are placed in one doubly linked list...
*/
SFG_Menu* fgGetActiveMenu( )