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:
parent
e8cfcd2247
commit
06174f9086
@ -164,7 +164,7 @@ static void fghcbDisplayWindow( SFG_Window *window, SFG_Enumerator *enumerator )
|
||||
( window->State.Redisplay == TRUE ) &&
|
||||
( window->State.Visible == TRUE ) )
|
||||
{
|
||||
SFG_Window *current_window = fgStructure.Window ;
|
||||
SFG_Window *current_window = fgStructure.Window;
|
||||
|
||||
window->State.Redisplay = FALSE;
|
||||
INVOKE_WCB( *window, Display, ( ) );
|
||||
@ -304,12 +304,12 @@ long fgElapsedTime( void )
|
||||
|
||||
gettimeofday( &now, NULL );
|
||||
|
||||
elapsed = (now.tv_usec - fgState.Time.Value.tv_usec) / 1000;
|
||||
elapsed += (now.tv_sec - fgState.Time.Value.tv_sec) * 1000;
|
||||
elapsed = ( now.tv_usec - fgState.Time.Value.tv_usec ) / 1000;
|
||||
elapsed += ( now.tv_sec - fgState.Time.Value.tv_sec ) * 1000;
|
||||
|
||||
return elapsed;
|
||||
#elif TARGET_HOST_WIN32
|
||||
return timeGetTime() - fgState.Time.Value;
|
||||
return timeGetTime( ) - fgState.Time.Value;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
@ -332,9 +332,9 @@ void fgError( const char *fmt, ... )
|
||||
|
||||
va_start( ap, fmt );
|
||||
|
||||
fprintf( stderr, "freeglut ");
|
||||
fprintf( stderr, "freeglut " );
|
||||
if( fgState.ProgramName )
|
||||
fprintf (stderr, "(%s): ", fgState.ProgramName);
|
||||
fprintf( stderr, "(%s): ", fgState.ProgramName );
|
||||
vfprintf( stderr, fmt, ap );
|
||||
fprintf( stderr, "\n" );
|
||||
|
||||
@ -352,7 +352,7 @@ void fgWarning( const char *fmt, ... )
|
||||
|
||||
va_start( ap, fmt );
|
||||
|
||||
fprintf( stderr, "freeglut ");
|
||||
fprintf( stderr, "freeglut " );
|
||||
if( fgState.ProgramName )
|
||||
fprintf( stderr, "(%s): ", fgState.ProgramName );
|
||||
vfprintf( stderr, fmt, ap );
|
||||
@ -381,7 +381,7 @@ void fgWarning( const char *fmt, ... )
|
||||
* 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 ) )
|
||||
{
|
||||
@ -398,7 +398,7 @@ static int fgHaveJoystick( void )
|
||||
fgEnumWindows( fgCheckJoystickCallback, &enumerator );
|
||||
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 )
|
||||
{
|
||||
@ -407,7 +407,7 @@ static void fgHavePendingRedisplaysCallback( SFG_Window* w, SFG_Enumerator* e)
|
||||
}
|
||||
fgEnumSubWindows( w, fgHavePendingRedisplaysCallback, e );
|
||||
}
|
||||
static int fgHavePendingRedisplays (void)
|
||||
static int fgHavePendingRedisplays( void )
|
||||
{
|
||||
SFG_Enumerator enumerator;
|
||||
enumerator.found = FALSE;
|
||||
@ -427,14 +427,14 @@ static int fgHaveTimers( void )
|
||||
*/
|
||||
static long fgNextTimer( void )
|
||||
{
|
||||
long now = fgElapsedTime();
|
||||
long now = fgElapsedTime( );
|
||||
long ret = INT_MAX;
|
||||
SFG_Timer *timer;
|
||||
|
||||
for( timer = (SFG_Timer *)fgState.Timers.First;
|
||||
for( timer = ( SFG_Timer * )fgState.Timers.First;
|
||||
timer;
|
||||
timer = (SFG_Timer *)timer->Node.Next )
|
||||
ret = MIN( ret, MAX( 0, (timer->TriggerTime) - now ) );
|
||||
timer = ( SFG_Timer * )timer->Node.Next )
|
||||
ret = MIN( ret, MAX( 0, timer->TriggerTime - now ) );
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -462,11 +462,11 @@ static void fgSleepForEvents( void )
|
||||
msec = MIN( msec, 10 );
|
||||
|
||||
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 );
|
||||
|
||||
if( -1 == err )
|
||||
printf( "freeglut select() error: %d\n", errno );
|
||||
fgWarning( "freeglut select() error: %d\n", errno );
|
||||
|
||||
#elif TARGET_HOST_WIN32
|
||||
#endif
|
||||
@ -531,7 +531,7 @@ void FGAPIENTRY glutMainLoopEvent( void )
|
||||
{
|
||||
GETWINDOW( xclient );
|
||||
|
||||
fgCloseWindow ( window ) ;
|
||||
fgCloseWindow ( window );
|
||||
fgAddToWindowDestroyList ( window, FALSE );
|
||||
}
|
||||
break;
|
||||
@ -656,8 +656,8 @@ void FGAPIENTRY glutMainLoopEvent( void )
|
||||
window->ActiveMenu->Window->State.MouseY =
|
||||
event.xmotion.y_root - window->ActiveMenu->Y;
|
||||
}
|
||||
window->ActiveMenu->Window->State.Redisplay = TRUE ;
|
||||
fgSetWindow( window->ActiveMenu->ParentWindow ) ;
|
||||
window->ActiveMenu->Window->State.Redisplay = TRUE;
|
||||
fgSetWindow( window->ActiveMenu->ParentWindow );
|
||||
|
||||
break;
|
||||
}
|
||||
@ -666,11 +666,9 @@ void FGAPIENTRY glutMainLoopEvent( void )
|
||||
* XXX For more than 5 buttons, just check {event.xmotion.state},
|
||||
* XXX rather than a host of bit-masks?
|
||||
*/
|
||||
if( (event.xmotion.state & Button1Mask) ||
|
||||
(event.xmotion.state & Button2Mask) ||
|
||||
(event.xmotion.state & Button3Mask) ||
|
||||
(event.xmotion.state & Button4Mask) ||
|
||||
(event.xmotion.state & Button5Mask) )
|
||||
#define BUTTON_MASK \
|
||||
( Button1Mask | Button2Mask | Button3Mask | Button4Mask | Button5Mask )
|
||||
if( event.xmotion.state & BUTTON_MASK )
|
||||
INVOKE_WCB( *window, Motion, ( event.xmotion.x,
|
||||
event.xmotion.y ) );
|
||||
else
|
||||
@ -686,7 +684,7 @@ void FGAPIENTRY glutMainLoopEvent( void )
|
||||
int button;
|
||||
|
||||
if( event.type == ButtonRelease )
|
||||
pressed = FALSE ;
|
||||
pressed = FALSE;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
if( ( 0 <= button ) &&
|
||||
( 2 >= button ) &&
|
||||
( FREEGLUT_MAX_MENUS > button ) &&
|
||||
( window->Menu[ button ] ) &&
|
||||
pressed )
|
||||
{
|
||||
@ -825,7 +823,7 @@ void FGAPIENTRY glutMainLoopEvent( void )
|
||||
* XXX Note that {button} has already been decremeted
|
||||
* XXX in mapping from X button numbering to GLUT.
|
||||
*/
|
||||
int wheel_number = (button - 3) / 2;
|
||||
int wheel_number = ( button - 3 ) / 2;
|
||||
int direction = -1;
|
||||
if( button % 2 )
|
||||
direction = 1;
|
||||
@ -879,7 +877,8 @@ void FGAPIENTRY glutMainLoopEvent( void )
|
||||
* Check for the ASCII/KeySym codes associated with the event:
|
||||
*/
|
||||
len = XLookupString( &event.xkey, asciiCode, sizeof(asciiCode),
|
||||
&keySym, &composeStatus );
|
||||
&keySym, &composeStatus
|
||||
);
|
||||
|
||||
/*
|
||||
* GLUT API tells us to have two separate callbacks...
|
||||
@ -894,7 +893,8 @@ void FGAPIENTRY glutMainLoopEvent( void )
|
||||
fgSetWindow( window );
|
||||
window->State.Modifiers = fgGetXModifiers( &event );
|
||||
keyboard_cb( asciiCode[ 0 ],
|
||||
event.xkey.x, event.xkey.y );
|
||||
event.xkey.x, event.xkey.y
|
||||
);
|
||||
window->State.Modifiers = 0xffffffff;
|
||||
}
|
||||
}
|
||||
@ -942,7 +942,7 @@ void FGAPIENTRY glutMainLoopEvent( void )
|
||||
* Execute the callback (if one has been specified),
|
||||
* given that the special code seems to be valid...
|
||||
*/
|
||||
if( special_cb && (special != -1) )
|
||||
if( special_cb && ( special != -1 ) )
|
||||
{
|
||||
fgSetWindow( window );
|
||||
window->State.Modifiers = fgGetXModifiers( &event );
|
||||
@ -958,7 +958,7 @@ void FGAPIENTRY glutMainLoopEvent( void )
|
||||
break; /* XXX Should disable this event */
|
||||
|
||||
default:
|
||||
fgWarning ("Unknown X event type: %d", event.type);
|
||||
fgWarning( "Unknown X event type: %d", event.type );
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -970,7 +970,7 @@ void FGAPIENTRY glutMainLoopEvent( void )
|
||||
while( PeekMessage( &stMsg, NULL, 0, 0, PM_NOREMOVE ) )
|
||||
{
|
||||
if( GetMessage( &stMsg, NULL, 0, 0 ) == 0 )
|
||||
fgState.ExecState = GLUT_EXEC_STATE_STOP ;
|
||||
fgState.ExecState = GLUT_EXEC_STATE_STOP;
|
||||
|
||||
TranslateMessage( &stMsg );
|
||||
DispatchMessage( &stMsg );
|
||||
@ -991,7 +991,7 @@ void FGAPIENTRY glutMainLoopEvent( void )
|
||||
void FGAPIENTRY glutMainLoop( void )
|
||||
{
|
||||
#if TARGET_HOST_WIN32
|
||||
SFG_Window *window = (SFG_Window *)fgStructure.Windows.First ;
|
||||
SFG_Window *window = (SFG_Window *)fgStructure.Windows.First;
|
||||
#endif
|
||||
|
||||
freeglut_assert_ready;
|
||||
@ -1008,19 +1008,19 @@ void FGAPIENTRY glutMainLoop( void )
|
||||
*/
|
||||
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 ) );
|
||||
fgSetWindow( current_window );
|
||||
}
|
||||
|
||||
window = (SFG_Window *)window->Node.Next ;
|
||||
window = (SFG_Window *)window->Node.Next;
|
||||
}
|
||||
#endif
|
||||
|
||||
fgState.ExecState = GLUT_EXEC_STATE_RUNNING ;
|
||||
fgState.ExecState = GLUT_EXEC_STATE_RUNNING;
|
||||
while( fgState.ExecState == GLUT_EXEC_STATE_RUNNING )
|
||||
{
|
||||
glutMainLoopEvent( );
|
||||
@ -1032,7 +1032,7 @@ void FGAPIENTRY glutMainLoop( void )
|
||||
if( fgState.IdleCallback )
|
||||
fgState.IdleCallback( );
|
||||
|
||||
fgSleepForEvents();
|
||||
fgSleepForEvents( );
|
||||
}
|
||||
}
|
||||
|
||||
@ -1046,7 +1046,7 @@ void FGAPIENTRY glutMainLoop( void )
|
||||
fgDeinitialize( );
|
||||
|
||||
if( execState == GLUT_ACTION_EXIT )
|
||||
exit( 0 ) ;
|
||||
exit( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
@ -1055,7 +1055,7 @@ void FGAPIENTRY glutMainLoop( 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;
|
||||
|
||||
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,
|
||||
uMsg, wParam, lParam ); */
|
||||
@ -1109,7 +1109,8 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
|
||||
if( fgStructure.MenuContext )
|
||||
wglMakeCurrent( window->Window.Device,
|
||||
fgStructure.MenuContext->Context ) ;
|
||||
fgStructure.MenuContext->Context
|
||||
);
|
||||
else
|
||||
{
|
||||
fgStructure.MenuContext =
|
||||
@ -1118,7 +1119,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
wglCreateContext( window->Window.Device );
|
||||
}
|
||||
|
||||
/* window->Window.Context = wglGetCurrentContext () ; */
|
||||
/* window->Window.Context = wglGetCurrentContext( ); */
|
||||
window->Window.Context = wglCreateContext( window->Window.Device );
|
||||
}
|
||||
else
|
||||
@ -1149,12 +1150,12 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
break;
|
||||
#if 0
|
||||
case WM_SETFOCUS:
|
||||
printf("WM_SETFOCUS: %p\n", window );
|
||||
printf( "WM_SETFOCUS: %p\n", window );
|
||||
lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
|
||||
break;
|
||||
|
||||
case WM_ACTIVATE:
|
||||
if (LOWORD(wParam) != WA_INACTIVE)
|
||||
if( LOWORD( wParam ) != WA_INACTIVE )
|
||||
{
|
||||
/* glutSetCursor( fgStructure.Window->State.Cursor ); */
|
||||
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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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 ((LOWORD(lParam) == HTCLIENT) &&
|
||||
(fgStructure.Window->State.Cursor == GLUT_CURSOR_NONE))
|
||||
if( ( LOWORD( lParam ) == HTCLIENT ) &&
|
||||
( fgStructure.Window->State.Cursor == GLUT_CURSOR_NONE ) )
|
||||
SetCursor( NULL );
|
||||
#else
|
||||
|
||||
@ -1231,8 +1239,8 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
*/
|
||||
if( fgStructure.Window == window )
|
||||
{
|
||||
int used = FALSE ;
|
||||
SFG_Window *iter ;
|
||||
int used = FALSE;
|
||||
SFG_Window *iter;
|
||||
|
||||
wglMakeCurrent( NULL, NULL );
|
||||
/*
|
||||
@ -1306,6 +1314,15 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
window->State.MouseX = LOWORD( 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 )
|
||||
{
|
||||
case WM_LBUTTONDOWN:
|
||||
@ -1334,6 +1351,9 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM 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
|
||||
* menu is hooked to this button.
|
||||
* 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 */
|
||||
if( window->ActiveMenu )
|
||||
{
|
||||
/* Inside the menu, invoke the callback and deactivate the menu*/
|
||||
if( fgCheckActiveMenu( window, window->ActiveMenu ) == TRUE )
|
||||
/* Outside the menu, deactivate the menu if it's a downclick */
|
||||
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
|
||||
@ -1374,11 +1399,6 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
fgSetWindow( save_window );
|
||||
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
|
||||
@ -1390,7 +1410,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
break;
|
||||
}
|
||||
|
||||
if ( ( window->Menu[ button ] ) && ( pressed == TRUE ) )
|
||||
if( ( window->Menu[ button ] ) && ( pressed == TRUE ) )
|
||||
{
|
||||
window->State.Redisplay = TRUE;
|
||||
fgSetWindow( window );
|
||||
@ -1421,10 +1441,12 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
case 0x020a:
|
||||
/* 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 );
|
||||
/* THIS IS SPECULATIVE -- John Fay, 10/2/03 */
|
||||
short ticks = ( short )HIWORD( wParam ) / 120;
|
||||
/* Should be WHEEL_DELTA instead of 120 */
|
||||
int direction = 1;
|
||||
|
||||
if( ticks < 0 )
|
||||
@ -1478,13 +1500,13 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
|
||||
fgStructure.Window->State.Modifiers = 0xffffffff;
|
||||
}
|
||||
break ;
|
||||
break;
|
||||
|
||||
case WM_SYSKEYDOWN:
|
||||
case WM_KEYDOWN:
|
||||
{
|
||||
int keypress = -1;
|
||||
POINT mouse_pos ;
|
||||
POINT mouse_pos;
|
||||
|
||||
if( fgState.IgnoreKeyRepeat && (lParam & KF_REPEAT) )
|
||||
break;
|
||||
@ -1712,58 +1734,57 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
*/
|
||||
switch ( lParam )
|
||||
{
|
||||
case SC_SIZE :
|
||||
break ;
|
||||
case SC_SIZE:
|
||||
break;
|
||||
|
||||
case SC_MOVE :
|
||||
break ;
|
||||
case SC_MOVE:
|
||||
break;
|
||||
|
||||
case SC_MINIMIZE :
|
||||
case SC_MINIMIZE:
|
||||
/* User has clicked on the "-" to minimize the window */
|
||||
/* Turn off the visibility */
|
||||
window->State.Visible = GL_FALSE ;
|
||||
window->State.Visible = GL_FALSE;
|
||||
break;
|
||||
|
||||
break ;
|
||||
case SC_MAXIMIZE:
|
||||
break;
|
||||
|
||||
case SC_MAXIMIZE :
|
||||
break ;
|
||||
case SC_NEXTWINDOW:
|
||||
break;
|
||||
|
||||
case SC_NEXTWINDOW :
|
||||
break ;
|
||||
case SC_PREVWINDOW:
|
||||
break;
|
||||
|
||||
case SC_PREVWINDOW :
|
||||
break ;
|
||||
|
||||
case SC_CLOSE :
|
||||
case SC_CLOSE:
|
||||
/* Followed very closely by a WM_CLOSE message */
|
||||
break ;
|
||||
break;
|
||||
|
||||
case SC_VSCROLL :
|
||||
break ;
|
||||
case SC_VSCROLL:
|
||||
break;
|
||||
|
||||
case SC_HSCROLL :
|
||||
break ;
|
||||
case SC_HSCROLL:
|
||||
break;
|
||||
|
||||
case SC_MOUSEMENU :
|
||||
break ;
|
||||
case SC_MOUSEMENU:
|
||||
break;
|
||||
|
||||
case SC_KEYMENU :
|
||||
break ;
|
||||
case SC_KEYMENU:
|
||||
break;
|
||||
|
||||
case SC_ARRANGE :
|
||||
break ;
|
||||
case SC_ARRANGE:
|
||||
break;
|
||||
|
||||
case SC_RESTORE :
|
||||
break ;
|
||||
case SC_RESTORE:
|
||||
break;
|
||||
|
||||
case SC_TASKLIST :
|
||||
break ;
|
||||
case SC_TASKLIST:
|
||||
break;
|
||||
|
||||
case SC_SCREENSAVE :
|
||||
break ;
|
||||
case SC_SCREENSAVE:
|
||||
break;
|
||||
|
||||
case SC_HOTKEY :
|
||||
break ;
|
||||
case SC_HOTKEY:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -183,10 +183,8 @@ static GLboolean fghCheckMenuStatus( SFG_Window* window, SFG_Menu* menu )
|
||||
* was a submenu then deactivate it.
|
||||
*/
|
||||
if( menu->ActiveEntry && ( menuEntry != menu->ActiveEntry ) )
|
||||
{
|
||||
if( menu->ActiveEntry->SubMenu )
|
||||
fgDeactivateSubMenu( menu->ActiveEntry );
|
||||
}
|
||||
|
||||
menu->ActiveEntry = menuEntry;
|
||||
menu->IsActive = TRUE;
|
||||
@ -341,7 +339,7 @@ static void fghDisplayMenuBox( SFG_Menu* menu )
|
||||
|
||||
glColor4fv( menu_pen_fore );
|
||||
|
||||
for( menuEntry = (SFG_MenuEntry *)menu->Entries.First, i=0;
|
||||
for( menuEntry = (SFG_MenuEntry *)menu->Entries.First, i = 0;
|
||||
menuEntry;
|
||||
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*/
|
||||
glRasterPos2i(
|
||||
2 * border,
|
||||
(i + 1)*FREEGLUT_MENU_HEIGHT -
|
||||
(int)( FREEGLUT_MENU_HEIGHT*0.3 - border )
|
||||
( i + 1 )*FREEGLUT_MENU_HEIGHT -
|
||||
( 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 y_base = i*FREEGLUT_MENU_HEIGHT + border;
|
||||
glBegin( GL_TRIANGLES );
|
||||
glVertex2i( x_base, y_base + 2 * border);
|
||||
glVertex2i( x_base, y_base + 2*border);
|
||||
glVertex2i( menu->Width - 2, y_base +
|
||||
( FREEGLUT_MENU_HEIGHT + border) / 2 );
|
||||
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:
|
||||
*/
|
||||
for( menuEntry = (SFG_MenuEntry *)menu->Entries.First;
|
||||
for( menuEntry = ( SFG_MenuEntry * )menu->Entries.First;
|
||||
menuEntry;
|
||||
menuEntry = (SFG_MenuEntry *)menuEntry->Node.Next )
|
||||
menuEntry = ( SFG_MenuEntry * )menuEntry->Node.Next )
|
||||
{
|
||||
/*
|
||||
* 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
|
||||
* of its submenus
|
||||
*/
|
||||
static void fghSetSubmenuParentWindow ( SFG_Window *window, SFG_Menu *menu )
|
||||
static void fghSetSubmenuParentWindow( SFG_Window *window, SFG_Menu *menu )
|
||||
{
|
||||
SFG_MenuEntry *menuEntry;
|
||||
|
||||
menu->ParentWindow = window;
|
||||
|
||||
for( menuEntry = (SFG_MenuEntry *)menu->Entries.First;
|
||||
for( menuEntry = ( SFG_MenuEntry * )menu->Entries.First;
|
||||
menuEntry;
|
||||
menuEntry = (SFG_MenuEntry *)menuEntry->Node.Next )
|
||||
if ( menuEntry->SubMenu )
|
||||
fghSetSubmenuParentWindow ( window, menuEntry->SubMenu ) ;
|
||||
menuEntry = ( SFG_MenuEntry * )menuEntry->Node.Next )
|
||||
if( menuEntry->SubMenu )
|
||||
fghSetSubmenuParentWindow( window, menuEntry->SubMenu );
|
||||
}
|
||||
|
||||
|
||||
@ -437,26 +435,16 @@ void fgDisplayMenu( void )
|
||||
SFG_Window* window = fgStructure.Window;
|
||||
SFG_Menu* menu = NULL;
|
||||
|
||||
/*
|
||||
* Make sure there is a current window available
|
||||
*/
|
||||
freeglut_assert_window;
|
||||
|
||||
/*
|
||||
* Check if there is an active menu attached to this window...
|
||||
*/
|
||||
menu = window->ActiveMenu;
|
||||
|
||||
/*
|
||||
* Did we find an active 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 |
|
||||
GL_POLYGON_BIT );
|
||||
|
||||
@ -465,38 +453,22 @@ void fgDisplayMenu( void )
|
||||
glDisable( GL_LIGHTING );
|
||||
glDisable( GL_CULL_FACE );
|
||||
|
||||
/*
|
||||
* We'll use an orthogonal projection matrix to draw the menu:
|
||||
*/
|
||||
glMatrixMode( GL_PROJECTION );
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
glPushMatrix( );
|
||||
glLoadIdentity( );
|
||||
glOrtho(
|
||||
0, glutGet( GLUT_WINDOW_WIDTH ),
|
||||
glutGet( GLUT_WINDOW_HEIGHT ), 0,
|
||||
-1, 1
|
||||
);
|
||||
|
||||
/*
|
||||
* Model-view matix gets reset to identity:
|
||||
*/
|
||||
glMatrixMode( GL_MODELVIEW );
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
glPushMatrix( );
|
||||
glLoadIdentity( );
|
||||
|
||||
/*
|
||||
* First of all, have the exact menu status check:
|
||||
*/
|
||||
fghCheckMenuStatus( window, menu );
|
||||
|
||||
/*
|
||||
* The status has been updated and we're ready to have the menu drawn now:
|
||||
*/
|
||||
fghDisplayMenuBox( menu );
|
||||
|
||||
/*
|
||||
* Restore the old OpenGL settings now
|
||||
*/
|
||||
glPopAttrib( );
|
||||
|
||||
glMatrixMode( GL_PROJECTION );
|
||||
@ -506,9 +478,6 @@ void fgDisplayMenu( void )
|
||||
|
||||
glutSwapBuffers( );
|
||||
|
||||
/*
|
||||
* Restore the current window
|
||||
*/
|
||||
fgSetWindow ( window );
|
||||
}
|
||||
|
||||
@ -532,7 +501,6 @@ void fgActivateMenu( SFG_Window* window, int button )
|
||||
/*
|
||||
* Set up the initial menu position now:
|
||||
*/
|
||||
|
||||
menu->X = window->State.MouseX + glutGet( GLUT_WINDOW_X );
|
||||
menu->Y = window->State.MouseY + glutGet( GLUT_WINDOW_Y );
|
||||
|
||||
@ -584,34 +552,13 @@ void fgExecuteMenuCallback( SFG_Menu* menu )
|
||||
menuEntry;
|
||||
menuEntry = (SFG_MenuEntry *)menuEntry->Node.Next)
|
||||
{
|
||||
/*
|
||||
* Is this menu entry active?
|
||||
*/
|
||||
if( menuEntry->IsActive == TRUE )
|
||||
{
|
||||
/*
|
||||
* If there is not a sub menu, execute the menu callback and
|
||||
* return...
|
||||
*/
|
||||
if( !( menuEntry->SubMenu ) )
|
||||
{
|
||||
/*
|
||||
* ...certainly given that there is one...
|
||||
*/
|
||||
if( menuEntry->SubMenu )
|
||||
fgExecuteMenuCallback( menuEntry->SubMenu );
|
||||
else
|
||||
if( menu->Callback )
|
||||
menu->Callback( menuEntry->ID );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Otherwise recurse into the submenu.
|
||||
*/
|
||||
fgExecuteMenuCallback( menuEntry->SubMenu );
|
||||
|
||||
/*
|
||||
* There is little sense in dwelling the search on
|
||||
*/
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -653,9 +600,9 @@ void fgDeactivateMenu( SFG_Window *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 = (SFG_MenuEntry *)menuEntry->Node.Next )
|
||||
menuEntry = ( SFG_MenuEntry * )menuEntry->Node.Next )
|
||||
{
|
||||
/*
|
||||
* Is that an active submenu by any case?
|
||||
@ -664,7 +611,7 @@ void fgDeactivateMenu( SFG_Window *window )
|
||||
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:
|
||||
*/
|
||||
for( menuEntry = (SFG_MenuEntry *)fgStructure.Menu->Entries.First;
|
||||
for( menuEntry = ( SFG_MenuEntry * )fgStructure.Menu->Entries.First;
|
||||
menuEntry;
|
||||
menuEntry = (SFG_MenuEntry *)menuEntry->Node.Next)
|
||||
menuEntry = ( SFG_MenuEntry * )menuEntry->Node.Next )
|
||||
{
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
int FGAPIENTRY glutCreateMenu( void (* callback)( int ) )
|
||||
int FGAPIENTRY glutCreateMenu( void(* callback)( int ) )
|
||||
{
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
void FGAPIENTRY glutAddSubMenu( const char* label, int subMenuID )
|
||||
void FGAPIENTRY glutAddSubMenu( const char *label, int subMenuID )
|
||||
{
|
||||
SFG_MenuEntry* menuEntry =
|
||||
(SFG_MenuEntry *)calloc( sizeof(SFG_MenuEntry), 1 );
|
||||
SFG_Menu* subMenu = fgMenuByID( subMenuID );
|
||||
SFG_MenuEntry *menuEntry =
|
||||
( SFG_MenuEntry * )calloc( sizeof( SFG_MenuEntry ), 1 );
|
||||
SFG_Menu *subMenu = fgMenuByID( subMenuID );
|
||||
|
||||
freeglut_assert_ready;
|
||||
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.
|
||||
*/
|
||||
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_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
|
||||
*/
|
||||
fghSetSubmenuParentWindow ( fgStructure.Window, fgStructure.Menu ) ;
|
||||
fghSetSubmenuParentWindow( fgStructure.Window, fgStructure.Menu );
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user