Normalized the spacing around symbols, for the most part. Ho-hum.

git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@351 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
rkrolib 2003-11-15 17:48:43 +00:00
parent e8cfcd2247
commit 06174f9086
2 changed files with 160 additions and 191 deletions

View File

@ -164,7 +164,7 @@ static void fghcbDisplayWindow( SFG_Window *window, SFG_Enumerator *enumerator )
( window->State.Redisplay == TRUE ) && ( window->State.Redisplay == TRUE ) &&
( window->State.Visible == TRUE ) ) ( window->State.Visible == TRUE ) )
{ {
SFG_Window *current_window = fgStructure.Window ; SFG_Window *current_window = fgStructure.Window;
window->State.Redisplay = FALSE; window->State.Redisplay = FALSE;
INVOKE_WCB( *window, Display, ( ) ); INVOKE_WCB( *window, Display, ( ) );
@ -304,12 +304,12 @@ long fgElapsedTime( void )
gettimeofday( &now, NULL ); gettimeofday( &now, NULL );
elapsed = (now.tv_usec - fgState.Time.Value.tv_usec) / 1000; elapsed = ( now.tv_usec - fgState.Time.Value.tv_usec ) / 1000;
elapsed += (now.tv_sec - fgState.Time.Value.tv_sec) * 1000; elapsed += ( now.tv_sec - fgState.Time.Value.tv_sec ) * 1000;
return elapsed; return elapsed;
#elif TARGET_HOST_WIN32 #elif TARGET_HOST_WIN32
return timeGetTime() - fgState.Time.Value; return timeGetTime( ) - fgState.Time.Value;
#endif #endif
} }
else else
@ -332,9 +332,9 @@ void fgError( const char *fmt, ... )
va_start( ap, fmt ); va_start( ap, fmt );
fprintf( stderr, "freeglut "); fprintf( stderr, "freeglut " );
if( fgState.ProgramName ) if( fgState.ProgramName )
fprintf (stderr, "(%s): ", fgState.ProgramName); fprintf( stderr, "(%s): ", fgState.ProgramName );
vfprintf( stderr, fmt, ap ); vfprintf( stderr, fmt, ap );
fprintf( stderr, "\n" ); fprintf( stderr, "\n" );
@ -352,7 +352,7 @@ void fgWarning( const char *fmt, ... )
va_start( ap, fmt ); va_start( ap, fmt );
fprintf( stderr, "freeglut "); fprintf( stderr, "freeglut " );
if( fgState.ProgramName ) if( fgState.ProgramName )
fprintf( stderr, "(%s): ", fgState.ProgramName ); fprintf( stderr, "(%s): ", fgState.ProgramName );
vfprintf( stderr, fmt, ap ); vfprintf( stderr, fmt, ap );
@ -381,7 +381,7 @@ void fgWarning( const char *fmt, ... )
* an opaque wall. * an opaque wall.
* *
*/ */
static void fgCheckJoystickCallback( SFG_Window* w, SFG_Enumerator* e) static void fgCheckJoystickCallback( SFG_Window* w, SFG_Enumerator* e )
{ {
if( FETCH_WCB( *w, Joystick ) ) if( FETCH_WCB( *w, Joystick ) )
{ {
@ -398,7 +398,7 @@ static int fgHaveJoystick( void )
fgEnumWindows( fgCheckJoystickCallback, &enumerator ); fgEnumWindows( fgCheckJoystickCallback, &enumerator );
return !!enumerator.data; return !!enumerator.data;
} }
static void fgHavePendingRedisplaysCallback( SFG_Window* w, SFG_Enumerator* e) static void fgHavePendingRedisplaysCallback( SFG_Window* w, SFG_Enumerator* e )
{ {
if( w->State.Redisplay ) if( w->State.Redisplay )
{ {
@ -407,7 +407,7 @@ static void fgHavePendingRedisplaysCallback( SFG_Window* w, SFG_Enumerator* e)
} }
fgEnumSubWindows( w, fgHavePendingRedisplaysCallback, e ); fgEnumSubWindows( w, fgHavePendingRedisplaysCallback, e );
} }
static int fgHavePendingRedisplays (void) static int fgHavePendingRedisplays( void )
{ {
SFG_Enumerator enumerator; SFG_Enumerator enumerator;
enumerator.found = FALSE; enumerator.found = FALSE;
@ -427,14 +427,14 @@ static int fgHaveTimers( void )
*/ */
static long fgNextTimer( void ) static long fgNextTimer( void )
{ {
long now = fgElapsedTime(); long now = fgElapsedTime( );
long ret = INT_MAX; long ret = INT_MAX;
SFG_Timer *timer; SFG_Timer *timer;
for( timer = (SFG_Timer *)fgState.Timers.First; for( timer = ( SFG_Timer * )fgState.Timers.First;
timer; timer;
timer = (SFG_Timer *)timer->Node.Next ) timer = ( SFG_Timer * )timer->Node.Next )
ret = MIN( ret, MAX( 0, (timer->TriggerTime) - now ) ); ret = MIN( ret, MAX( 0, timer->TriggerTime - now ) );
return ret; return ret;
} }
@ -462,11 +462,11 @@ static void fgSleepForEvents( void )
msec = MIN( msec, 10 ); msec = MIN( msec, 10 );
wait.tv_sec = msec / 1000; wait.tv_sec = msec / 1000;
wait.tv_usec = (msec % 1000) * 1000; wait.tv_usec = ( msec % 1000 ) * 1000;
err = select( socket+1, &fdset, NULL, NULL, &wait ); err = select( socket+1, &fdset, NULL, NULL, &wait );
if( -1 == err ) if( -1 == err )
printf( "freeglut select() error: %d\n", errno ); fgWarning( "freeglut select() error: %d\n", errno );
#elif TARGET_HOST_WIN32 #elif TARGET_HOST_WIN32
#endif #endif
@ -531,7 +531,7 @@ void FGAPIENTRY glutMainLoopEvent( void )
{ {
GETWINDOW( xclient ); GETWINDOW( xclient );
fgCloseWindow ( window ) ; fgCloseWindow ( window );
fgAddToWindowDestroyList ( window, FALSE ); fgAddToWindowDestroyList ( window, FALSE );
} }
break; break;
@ -656,8 +656,8 @@ void FGAPIENTRY glutMainLoopEvent( void )
window->ActiveMenu->Window->State.MouseY = window->ActiveMenu->Window->State.MouseY =
event.xmotion.y_root - window->ActiveMenu->Y; event.xmotion.y_root - window->ActiveMenu->Y;
} }
window->ActiveMenu->Window->State.Redisplay = TRUE ; window->ActiveMenu->Window->State.Redisplay = TRUE;
fgSetWindow( window->ActiveMenu->ParentWindow ) ; fgSetWindow( window->ActiveMenu->ParentWindow );
break; break;
} }
@ -666,11 +666,9 @@ void FGAPIENTRY glutMainLoopEvent( void )
* XXX For more than 5 buttons, just check {event.xmotion.state}, * XXX For more than 5 buttons, just check {event.xmotion.state},
* XXX rather than a host of bit-masks? * XXX rather than a host of bit-masks?
*/ */
if( (event.xmotion.state & Button1Mask) || #define BUTTON_MASK \
(event.xmotion.state & Button2Mask) || ( Button1Mask | Button2Mask | Button3Mask | Button4Mask | Button5Mask )
(event.xmotion.state & Button3Mask) || if( event.xmotion.state & BUTTON_MASK )
(event.xmotion.state & Button4Mask) ||
(event.xmotion.state & Button5Mask) )
INVOKE_WCB( *window, Motion, ( event.xmotion.x, INVOKE_WCB( *window, Motion, ( event.xmotion.x,
event.xmotion.y ) ); event.xmotion.y ) );
else else
@ -686,7 +684,7 @@ void FGAPIENTRY glutMainLoopEvent( void )
int button; int button;
if( event.type == ButtonRelease ) if( event.type == ButtonRelease )
pressed = FALSE ; pressed = FALSE;
/* /*
* A mouse button has been pressed or released. Traditionally, * A mouse button has been pressed or released. Traditionally,
@ -777,7 +775,7 @@ void FGAPIENTRY glutMainLoopEvent( void )
* No active menu, let's check whether we need to activate one. * No active menu, let's check whether we need to activate one.
*/ */
if( ( 0 <= button ) && if( ( 0 <= button ) &&
( 2 >= button ) && ( FREEGLUT_MAX_MENUS > button ) &&
( window->Menu[ button ] ) && ( window->Menu[ button ] ) &&
pressed ) pressed )
{ {
@ -825,7 +823,7 @@ void FGAPIENTRY glutMainLoopEvent( void )
* XXX Note that {button} has already been decremeted * XXX Note that {button} has already been decremeted
* XXX in mapping from X button numbering to GLUT. * XXX in mapping from X button numbering to GLUT.
*/ */
int wheel_number = (button - 3) / 2; int wheel_number = ( button - 3 ) / 2;
int direction = -1; int direction = -1;
if( button % 2 ) if( button % 2 )
direction = 1; direction = 1;
@ -879,7 +877,8 @@ void FGAPIENTRY glutMainLoopEvent( void )
* Check for the ASCII/KeySym codes associated with the event: * Check for the ASCII/KeySym codes associated with the event:
*/ */
len = XLookupString( &event.xkey, asciiCode, sizeof(asciiCode), len = XLookupString( &event.xkey, asciiCode, sizeof(asciiCode),
&keySym, &composeStatus ); &keySym, &composeStatus
);
/* /*
* GLUT API tells us to have two separate callbacks... * GLUT API tells us to have two separate callbacks...
@ -894,7 +893,8 @@ void FGAPIENTRY glutMainLoopEvent( void )
fgSetWindow( window ); fgSetWindow( window );
window->State.Modifiers = fgGetXModifiers( &event ); window->State.Modifiers = fgGetXModifiers( &event );
keyboard_cb( asciiCode[ 0 ], keyboard_cb( asciiCode[ 0 ],
event.xkey.x, event.xkey.y ); event.xkey.x, event.xkey.y
);
window->State.Modifiers = 0xffffffff; window->State.Modifiers = 0xffffffff;
} }
} }
@ -942,7 +942,7 @@ void FGAPIENTRY glutMainLoopEvent( void )
* Execute the callback (if one has been specified), * Execute the callback (if one has been specified),
* given that the special code seems to be valid... * given that the special code seems to be valid...
*/ */
if( special_cb && (special != -1) ) if( special_cb && ( special != -1 ) )
{ {
fgSetWindow( window ); fgSetWindow( window );
window->State.Modifiers = fgGetXModifiers( &event ); window->State.Modifiers = fgGetXModifiers( &event );
@ -958,7 +958,7 @@ void FGAPIENTRY glutMainLoopEvent( void )
break; /* XXX Should disable this event */ break; /* XXX Should disable this event */
default: default:
fgWarning ("Unknown X event type: %d", event.type); fgWarning( "Unknown X event type: %d", event.type );
break; break;
} }
} }
@ -970,7 +970,7 @@ void FGAPIENTRY glutMainLoopEvent( void )
while( PeekMessage( &stMsg, NULL, 0, 0, PM_NOREMOVE ) ) while( PeekMessage( &stMsg, NULL, 0, 0, PM_NOREMOVE ) )
{ {
if( GetMessage( &stMsg, NULL, 0, 0 ) == 0 ) if( GetMessage( &stMsg, NULL, 0, 0 ) == 0 )
fgState.ExecState = GLUT_EXEC_STATE_STOP ; fgState.ExecState = GLUT_EXEC_STATE_STOP;
TranslateMessage( &stMsg ); TranslateMessage( &stMsg );
DispatchMessage( &stMsg ); DispatchMessage( &stMsg );
@ -991,7 +991,7 @@ void FGAPIENTRY glutMainLoopEvent( void )
void FGAPIENTRY glutMainLoop( void ) void FGAPIENTRY glutMainLoop( void )
{ {
#if TARGET_HOST_WIN32 #if TARGET_HOST_WIN32
SFG_Window *window = (SFG_Window *)fgStructure.Windows.First ; SFG_Window *window = (SFG_Window *)fgStructure.Windows.First;
#endif #endif
freeglut_assert_ready; freeglut_assert_ready;
@ -1008,19 +1008,19 @@ void FGAPIENTRY glutMainLoop( void )
*/ */
while( window ) while( window )
{ {
if ( FETCH_WCB( *window, Visibility ) ) if( FETCH_WCB( *window, Visibility ) )
{ {
SFG_Window *current_window = fgStructure.Window ; SFG_Window *current_window = fgStructure.Window;
INVOKE_WCB( *window, Visibility, ( window->State.Visible ) ); INVOKE_WCB( *window, Visibility, ( window->State.Visible ) );
fgSetWindow( current_window ); fgSetWindow( current_window );
} }
window = (SFG_Window *)window->Node.Next ; window = (SFG_Window *)window->Node.Next;
} }
#endif #endif
fgState.ExecState = GLUT_EXEC_STATE_RUNNING ; fgState.ExecState = GLUT_EXEC_STATE_RUNNING;
while( fgState.ExecState == GLUT_EXEC_STATE_RUNNING ) while( fgState.ExecState == GLUT_EXEC_STATE_RUNNING )
{ {
glutMainLoopEvent( ); glutMainLoopEvent( );
@ -1032,7 +1032,7 @@ void FGAPIENTRY glutMainLoop( void )
if( fgState.IdleCallback ) if( fgState.IdleCallback )
fgState.IdleCallback( ); fgState.IdleCallback( );
fgSleepForEvents(); fgSleepForEvents( );
} }
} }
@ -1046,7 +1046,7 @@ void FGAPIENTRY glutMainLoop( void )
fgDeinitialize( ); fgDeinitialize( );
if( execState == GLUT_ACTION_EXIT ) if( execState == GLUT_ACTION_EXIT )
exit( 0 ) ; exit( 0 );
} }
} }
@ -1055,7 +1055,7 @@ void FGAPIENTRY glutMainLoop( void )
*/ */
void FGAPIENTRY glutLeaveMainLoop( void ) void FGAPIENTRY glutLeaveMainLoop( void )
{ {
fgState.ExecState = GLUT_EXEC_STATE_STOP ; fgState.ExecState = GLUT_EXEC_STATE_STOP;
} }
@ -1085,7 +1085,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
LONG lRet = 1; LONG lRet = 1;
if ( ( window == NULL ) && ( uMsg != WM_CREATE ) ) if ( ( window == NULL ) && ( uMsg != WM_CREATE ) )
return( DefWindowProc( hWnd, uMsg, wParam, lParam ) ); return DefWindowProc( hWnd, uMsg, wParam, lParam );
/* printf ( "Window %3d message <%04x> %12d %12d\n", window?window->ID:0, /* printf ( "Window %3d message <%04x> %12d %12d\n", window?window->ID:0,
uMsg, wParam, lParam ); */ uMsg, wParam, lParam ); */
@ -1109,7 +1109,8 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
if( fgStructure.MenuContext ) if( fgStructure.MenuContext )
wglMakeCurrent( window->Window.Device, wglMakeCurrent( window->Window.Device,
fgStructure.MenuContext->Context ) ; fgStructure.MenuContext->Context
);
else else
{ {
fgStructure.MenuContext = fgStructure.MenuContext =
@ -1118,7 +1119,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
wglCreateContext( window->Window.Device ); wglCreateContext( window->Window.Device );
} }
/* window->Window.Context = wglGetCurrentContext () ; */ /* window->Window.Context = wglGetCurrentContext( ); */
window->Window.Context = wglCreateContext( window->Window.Device ); window->Window.Context = wglCreateContext( window->Window.Device );
} }
else else
@ -1149,12 +1150,12 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
break; break;
#if 0 #if 0
case WM_SETFOCUS: case WM_SETFOCUS:
printf("WM_SETFOCUS: %p\n", window ); printf( "WM_SETFOCUS: %p\n", window );
lRet = DefWindowProc( hWnd, uMsg, wParam, lParam ); lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
break; break;
case WM_ACTIVATE: case WM_ACTIVATE:
if (LOWORD(wParam) != WA_INACTIVE) if( LOWORD( wParam ) != WA_INACTIVE )
{ {
/* glutSetCursor( fgStructure.Window->State.Cursor ); */ /* glutSetCursor( fgStructure.Window->State.Cursor ); */
printf("WM_ACTIVATE: glutSetCursor( %p, %d)\n", window, printf("WM_ACTIVATE: glutSetCursor( %p, %d)\n", window,
@ -1170,9 +1171,16 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
/* /*
* Windows seems to need reminding to erase the cursor for NONE. * Windows seems to need reminding to erase the cursor for NONE.
*/ */
/*
* XXX Is this #if 0 section anything that we need to worry
* XXX about? Can we delete it? If it will ever be used,
* XXX why not re-use some common code with the glutSetCursor()
* XXX function (or perhaps invoke glutSetCursor())?
*/
#if 0 #if 0
if ((LOWORD(lParam) == HTCLIENT) && if( ( LOWORD( lParam ) == HTCLIENT ) &&
(fgStructure.Window->State.Cursor == GLUT_CURSOR_NONE)) ( fgStructure.Window->State.Cursor == GLUT_CURSOR_NONE ) )
SetCursor( NULL ); SetCursor( NULL );
#else #else
@ -1231,8 +1239,8 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
*/ */
if( fgStructure.Window == window ) if( fgStructure.Window == window )
{ {
int used = FALSE ; int used = FALSE;
SFG_Window *iter ; SFG_Window *iter;
wglMakeCurrent( NULL, NULL ); wglMakeCurrent( NULL, NULL );
/* /*
@ -1306,6 +1314,15 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
window->State.MouseX = LOWORD( lParam ); window->State.MouseX = LOWORD( lParam );
window->State.MouseY = HIWORD( lParam ); window->State.MouseY = HIWORD( lParam );
/*
* XXX Either these multi-statement lines should be broken
* XXX in the form:
* XXX pressed = TRUE;
* XXX button = GLUT_LEFT_BUTTON;
* XXX break;
* XXX ...or we should use a macro (much as I dislike freeglut's
* XXX preponderance of using macros to "compress" code).
*/
switch( uMsg ) switch( uMsg )
{ {
case WM_LBUTTONDOWN: case WM_LBUTTONDOWN:
@ -1334,6 +1351,9 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
return DefWindowProc( hWnd, uMsg, lParam, wParam ); return DefWindowProc( hWnd, uMsg, lParam, wParam );
/* /*
* XXX This comment is duplicated in two other spots.
* XXX Can we centralize it?
*
* Do not execute the application's mouse callback if a * Do not execute the application's mouse callback if a
* menu is hooked to this button. * menu is hooked to this button.
* In that case an appropriate private call should be generated. * In that case an appropriate private call should be generated.
@ -1353,8 +1373,13 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
/* Window has an active menu, it absorbs any mouse click */ /* Window has an active menu, it absorbs any mouse click */
if( window->ActiveMenu ) if( window->ActiveMenu )
{ {
/* Inside the menu, invoke the callback and deactivate the menu*/ /* Outside the menu, deactivate the menu if it's a downclick */
if( fgCheckActiveMenu( window, window->ActiveMenu ) == TRUE ) if( fgCheckActiveMenu( window, window->ActiveMenu ) != TRUE )
{
if( pressed == TRUE )
fgDeactivateMenu( window->ActiveMenu->ParentWindow );
}
else /* In menu, invoke the callback and deactivate the menu*/
{ {
/* /*
* Save the current window and menu and set the current * Save the current window and menu and set the current
@ -1374,11 +1399,6 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
fgSetWindow( save_window ); fgSetWindow( save_window );
fgStructure.Menu = save_menu; fgStructure.Menu = save_menu;
} }
else /* Out of menu, deactivate the menu if it's a downclick */
{
if( pressed == TRUE )
fgDeactivateMenu( window->ActiveMenu->ParentWindow );
}
/* /*
* Let's make the window redraw as a result of the mouse * Let's make the window redraw as a result of the mouse
@ -1390,7 +1410,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
break; break;
} }
if ( ( window->Menu[ button ] ) && ( pressed == TRUE ) ) if( ( window->Menu[ button ] ) && ( pressed == TRUE ) )
{ {
window->State.Redisplay = TRUE; window->State.Redisplay = TRUE;
fgSetWindow( window ); fgSetWindow( window );
@ -1421,10 +1441,12 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
case 0x020a: case 0x020a:
/* Should be WM_MOUSEWHEEL but my compiler doesn't recognize it */ /* Should be WM_MOUSEWHEEL but my compiler doesn't recognize it */
{ {
/*
* XXX THIS IS SPECULATIVE -- John Fay, 10/2/03
* XXX Should use WHEEL_DELTA instead of 120
*/
int wheel_number = LOWORD( wParam ); int wheel_number = LOWORD( wParam );
/* THIS IS SPECULATIVE -- John Fay, 10/2/03 */
short ticks = ( short )HIWORD( wParam ) / 120; short ticks = ( short )HIWORD( wParam ) / 120;
/* Should be WHEEL_DELTA instead of 120 */
int direction = 1; int direction = 1;
if( ticks < 0 ) if( ticks < 0 )
@ -1478,13 +1500,13 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
fgStructure.Window->State.Modifiers = 0xffffffff; fgStructure.Window->State.Modifiers = 0xffffffff;
} }
break ; break;
case WM_SYSKEYDOWN: case WM_SYSKEYDOWN:
case WM_KEYDOWN: case WM_KEYDOWN:
{ {
int keypress = -1; int keypress = -1;
POINT mouse_pos ; POINT mouse_pos;
if( fgState.IgnoreKeyRepeat && (lParam & KF_REPEAT) ) if( fgState.IgnoreKeyRepeat && (lParam & KF_REPEAT) )
break; break;
@ -1712,58 +1734,57 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
*/ */
switch ( lParam ) switch ( lParam )
{ {
case SC_SIZE : case SC_SIZE:
break ; break;
case SC_MOVE : case SC_MOVE:
break ; break;
case SC_MINIMIZE : case SC_MINIMIZE:
/* User has clicked on the "-" to minimize the window */ /* User has clicked on the "-" to minimize the window */
/* Turn off the visibility */ /* Turn off the visibility */
window->State.Visible = GL_FALSE ; window->State.Visible = GL_FALSE;
break;
break ; case SC_MAXIMIZE:
break;
case SC_MAXIMIZE : case SC_NEXTWINDOW:
break ; break;
case SC_NEXTWINDOW : case SC_PREVWINDOW:
break ; break;
case SC_PREVWINDOW : case SC_CLOSE:
break ;
case SC_CLOSE :
/* Followed very closely by a WM_CLOSE message */ /* Followed very closely by a WM_CLOSE message */
break ; break;
case SC_VSCROLL : case SC_VSCROLL:
break ; break;
case SC_HSCROLL : case SC_HSCROLL:
break ; break;
case SC_MOUSEMENU : case SC_MOUSEMENU:
break ; break;
case SC_KEYMENU : case SC_KEYMENU:
break ; break;
case SC_ARRANGE : case SC_ARRANGE:
break ; break;
case SC_RESTORE : case SC_RESTORE:
break ; break;
case SC_TASKLIST : case SC_TASKLIST:
break ; break;
case SC_SCREENSAVE : case SC_SCREENSAVE:
break ; break;
case SC_HOTKEY : case SC_HOTKEY:
break ; break;
} }
} }

View File

@ -183,10 +183,8 @@ static GLboolean fghCheckMenuStatus( SFG_Window* window, SFG_Menu* menu )
* was a submenu then deactivate it. * was a submenu then deactivate it.
*/ */
if( menu->ActiveEntry && ( menuEntry != menu->ActiveEntry ) ) if( menu->ActiveEntry && ( menuEntry != menu->ActiveEntry ) )
{
if( menu->ActiveEntry->SubMenu ) if( menu->ActiveEntry->SubMenu )
fgDeactivateSubMenu( menu->ActiveEntry ); fgDeactivateSubMenu( menu->ActiveEntry );
}
menu->ActiveEntry = menuEntry; menu->ActiveEntry = menuEntry;
menu->IsActive = TRUE; menu->IsActive = TRUE;
@ -341,7 +339,7 @@ static void fghDisplayMenuBox( SFG_Menu* menu )
glColor4fv( menu_pen_fore ); glColor4fv( menu_pen_fore );
for( menuEntry = (SFG_MenuEntry *)menu->Entries.First, i=0; for( menuEntry = (SFG_MenuEntry *)menu->Entries.First, i = 0;
menuEntry; menuEntry;
menuEntry = (SFG_MenuEntry *)menuEntry->Node.Next, ++i ) menuEntry = (SFG_MenuEntry *)menuEntry->Node.Next, ++i )
{ {
@ -357,8 +355,8 @@ static void fghDisplayMenuBox( SFG_Menu* menu )
/* Try to center the text - JCJ 31 July 2003*/ /* Try to center the text - JCJ 31 July 2003*/
glRasterPos2i( glRasterPos2i(
2 * border, 2 * border,
(i + 1)*FREEGLUT_MENU_HEIGHT - ( i + 1 )*FREEGLUT_MENU_HEIGHT -
(int)( FREEGLUT_MENU_HEIGHT*0.3 - border ) ( int )( FREEGLUT_MENU_HEIGHT*0.3 - border )
); );
/* /*
@ -375,7 +373,7 @@ static void fghDisplayMenuBox( SFG_Menu* menu )
int x_base = menu->Width - 2 - width; int x_base = menu->Width - 2 - width;
int y_base = i*FREEGLUT_MENU_HEIGHT + border; int y_base = i*FREEGLUT_MENU_HEIGHT + border;
glBegin( GL_TRIANGLES ); glBegin( GL_TRIANGLES );
glVertex2i( x_base, y_base + 2 * border); glVertex2i( x_base, y_base + 2*border);
glVertex2i( menu->Width - 2, y_base + glVertex2i( menu->Width - 2, y_base +
( FREEGLUT_MENU_HEIGHT + border) / 2 ); ( FREEGLUT_MENU_HEIGHT + border) / 2 );
glVertex2i( x_base, y_base + FREEGLUT_MENU_HEIGHT - border ); glVertex2i( x_base, y_base + FREEGLUT_MENU_HEIGHT - border );
@ -392,9 +390,9 @@ static void fghDisplayMenuBox( SFG_Menu* menu )
/* /*
* Now we are ready to check if any of our children needs to be redrawn: * Now we are ready to check if any of our children needs to be redrawn:
*/ */
for( menuEntry = (SFG_MenuEntry *)menu->Entries.First; for( menuEntry = ( SFG_MenuEntry * )menu->Entries.First;
menuEntry; menuEntry;
menuEntry = (SFG_MenuEntry *)menuEntry->Node.Next ) menuEntry = ( SFG_MenuEntry * )menuEntry->Node.Next )
{ {
/* /*
* Is that an active sub menu by any case? * Is that an active sub menu by any case?
@ -415,17 +413,17 @@ static void fghDisplayMenuBox( SFG_Menu* menu )
* Private static function to set the parent window of a submenu and all * Private static function to set the parent window of a submenu and all
* of its submenus * of its submenus
*/ */
static void fghSetSubmenuParentWindow ( SFG_Window *window, SFG_Menu *menu ) static void fghSetSubmenuParentWindow( SFG_Window *window, SFG_Menu *menu )
{ {
SFG_MenuEntry *menuEntry; SFG_MenuEntry *menuEntry;
menu->ParentWindow = window; menu->ParentWindow = window;
for( menuEntry = (SFG_MenuEntry *)menu->Entries.First; for( menuEntry = ( SFG_MenuEntry * )menu->Entries.First;
menuEntry; menuEntry;
menuEntry = (SFG_MenuEntry *)menuEntry->Node.Next ) menuEntry = ( SFG_MenuEntry * )menuEntry->Node.Next )
if ( menuEntry->SubMenu ) if( menuEntry->SubMenu )
fghSetSubmenuParentWindow ( window, menuEntry->SubMenu ) ; fghSetSubmenuParentWindow( window, menuEntry->SubMenu );
} }
@ -437,26 +435,16 @@ void fgDisplayMenu( void )
SFG_Window* window = fgStructure.Window; SFG_Window* window = fgStructure.Window;
SFG_Menu* menu = NULL; SFG_Menu* menu = NULL;
/*
* Make sure there is a current window available
*/
freeglut_assert_window; freeglut_assert_window;
/* /*
* Check if there is an active menu attached to this window... * Check if there is an active menu attached to this window...
*/ */
menu = window->ActiveMenu; menu = window->ActiveMenu;
/*
* Did we find an active menu?
*/
freeglut_return_if_fail( menu ); freeglut_return_if_fail( menu );
fgSetWindow ( menu->Window ); fgSetWindow( menu->Window );
/*
* Prepare the OpenGL state to do the rendering first:
*/
glPushAttrib( GL_DEPTH_BUFFER_BIT | GL_TEXTURE_BIT | GL_LIGHTING_BIT | glPushAttrib( GL_DEPTH_BUFFER_BIT | GL_TEXTURE_BIT | GL_LIGHTING_BIT |
GL_POLYGON_BIT ); GL_POLYGON_BIT );
@ -465,38 +453,22 @@ void fgDisplayMenu( void )
glDisable( GL_LIGHTING ); glDisable( GL_LIGHTING );
glDisable( GL_CULL_FACE ); glDisable( GL_CULL_FACE );
/*
* We'll use an orthogonal projection matrix to draw the menu:
*/
glMatrixMode( GL_PROJECTION ); glMatrixMode( GL_PROJECTION );
glPushMatrix(); glPushMatrix( );
glLoadIdentity(); glLoadIdentity( );
glOrtho( glOrtho(
0, glutGet( GLUT_WINDOW_WIDTH ), 0, glutGet( GLUT_WINDOW_WIDTH ),
glutGet( GLUT_WINDOW_HEIGHT ), 0, glutGet( GLUT_WINDOW_HEIGHT ), 0,
-1, 1 -1, 1
); );
/*
* Model-view matix gets reset to identity:
*/
glMatrixMode( GL_MODELVIEW ); glMatrixMode( GL_MODELVIEW );
glPushMatrix(); glPushMatrix( );
glLoadIdentity(); glLoadIdentity( );
/*
* First of all, have the exact menu status check:
*/
fghCheckMenuStatus( window, menu ); fghCheckMenuStatus( window, menu );
/*
* The status has been updated and we're ready to have the menu drawn now:
*/
fghDisplayMenuBox( menu ); fghDisplayMenuBox( menu );
/*
* Restore the old OpenGL settings now
*/
glPopAttrib( ); glPopAttrib( );
glMatrixMode( GL_PROJECTION ); glMatrixMode( GL_PROJECTION );
@ -506,9 +478,6 @@ void fgDisplayMenu( void )
glutSwapBuffers( ); glutSwapBuffers( );
/*
* Restore the current window
*/
fgSetWindow ( window ); fgSetWindow ( window );
} }
@ -532,7 +501,6 @@ void fgActivateMenu( SFG_Window* window, int button )
/* /*
* Set up the initial menu position now: * Set up the initial menu position now:
*/ */
menu->X = window->State.MouseX + glutGet( GLUT_WINDOW_X ); menu->X = window->State.MouseX + glutGet( GLUT_WINDOW_X );
menu->Y = window->State.MouseY + glutGet( GLUT_WINDOW_Y ); menu->Y = window->State.MouseY + glutGet( GLUT_WINDOW_Y );
@ -584,34 +552,13 @@ void fgExecuteMenuCallback( SFG_Menu* menu )
menuEntry; menuEntry;
menuEntry = (SFG_MenuEntry *)menuEntry->Node.Next) menuEntry = (SFG_MenuEntry *)menuEntry->Node.Next)
{ {
/*
* Is this menu entry active?
*/
if( menuEntry->IsActive == TRUE ) if( menuEntry->IsActive == TRUE )
{ {
/* if( menuEntry->SubMenu )
* If there is not a sub menu, execute the menu callback and fgExecuteMenuCallback( menuEntry->SubMenu );
* return... else
*/
if( !( menuEntry->SubMenu ) )
{
/*
* ...certainly given that there is one...
*/
if( menu->Callback ) if( menu->Callback )
menu->Callback( menuEntry->ID ); menu->Callback( menuEntry->ID );
return;
}
/*
* Otherwise recurse into the submenu.
*/
fgExecuteMenuCallback( menuEntry->SubMenu );
/*
* There is little sense in dwelling the search on
*/
return; return;
} }
} }
@ -653,9 +600,9 @@ void fgDeactivateMenu( SFG_Window *window )
/* /*
* Hide all submenu windows, and the root menu's window. * Hide all submenu windows, and the root menu's window.
*/ */
for ( menuEntry = (SFG_MenuEntry *)menu->Entries.First; for ( menuEntry = ( SFG_MenuEntry * )menu->Entries.First;
menuEntry; menuEntry;
menuEntry = (SFG_MenuEntry *)menuEntry->Node.Next ) menuEntry = ( SFG_MenuEntry * )menuEntry->Node.Next )
{ {
/* /*
* Is that an active submenu by any case? * Is that an active submenu by any case?
@ -664,7 +611,7 @@ void fgDeactivateMenu( SFG_Window *window )
fgDeactivateSubMenu( menuEntry ); fgDeactivateSubMenu( menuEntry );
} }
fgSetWindow ( current_window ) ; fgSetWindow( current_window );
} }
/* /*
@ -720,9 +667,9 @@ void fghCalculateMenuBoxSize( void )
/* /*
* The menu's box size depends on the menu entries: * The menu's box size depends on the menu entries:
*/ */
for( menuEntry = (SFG_MenuEntry *)fgStructure.Menu->Entries.First; for( menuEntry = ( SFG_MenuEntry * )fgStructure.Menu->Entries.First;
menuEntry; menuEntry;
menuEntry = (SFG_MenuEntry *)menuEntry->Node.Next) menuEntry = ( SFG_MenuEntry * )menuEntry->Node.Next )
{ {
/* /*
* Update the menu entry's width value * Update the menu entry's width value
@ -759,7 +706,7 @@ void fghCalculateMenuBoxSize( void )
/* /*
* Creates a new menu object, adding it to the freeglut structure * Creates a new menu object, adding it to the freeglut structure
*/ */
int FGAPIENTRY glutCreateMenu( void (* callback)( int ) ) int FGAPIENTRY glutCreateMenu( void(* callback)( int ) )
{ {
/* /*
* The menu object creation code resides in freeglut_structure.c * The menu object creation code resides in freeglut_structure.c
@ -834,11 +781,11 @@ void FGAPIENTRY glutAddMenuEntry( const char* label, int value )
/* /*
* Add a sub menu to the bottom of the current menu * Add a sub menu to the bottom of the current menu
*/ */
void FGAPIENTRY glutAddSubMenu( const char* label, int subMenuID ) void FGAPIENTRY glutAddSubMenu( const char *label, int subMenuID )
{ {
SFG_MenuEntry* menuEntry = SFG_MenuEntry *menuEntry =
(SFG_MenuEntry *)calloc( sizeof(SFG_MenuEntry), 1 ); ( SFG_MenuEntry * )calloc( sizeof( SFG_MenuEntry ), 1 );
SFG_Menu* subMenu = fgMenuByID( subMenuID ); SFG_Menu *subMenu = fgMenuByID( subMenuID );
freeglut_assert_ready; freeglut_assert_ready;
freeglut_return_if_fail( fgStructure.Menu ); freeglut_return_if_fail( fgStructure.Menu );
@ -889,7 +836,8 @@ void FGAPIENTRY glutChangeToMenuEntry( int item, const char* label, int value )
/* /*
* Changes the specified menu item in the current menu into a sub-menu trigger. * Changes the specified menu item in the current menu into a sub-menu trigger.
*/ */
void FGAPIENTRY glutChangeToSubMenu( int item, const char* label, int subMenuID ) void FGAPIENTRY glutChangeToSubMenu( int item, const char* label,
int subMenuID )
{ {
SFG_Menu* subMenu = fgMenuByID( subMenuID ); SFG_Menu* subMenu = fgMenuByID( subMenuID );
SFG_MenuEntry* menuEntry = NULL; SFG_MenuEntry* menuEntry = NULL;
@ -960,7 +908,7 @@ void FGAPIENTRY glutAttachMenu( int button )
/* /*
* Make the parent window of the menu (and all submenus) the current window * Make the parent window of the menu (and all submenus) the current window
*/ */
fghSetSubmenuParentWindow ( fgStructure.Window, fgStructure.Menu ) ; fghSetSubmenuParentWindow( fgStructure.Window, fgStructure.Menu );
} }
/* /*