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

@ -434,7 +434,7 @@ static long fgNextTimer( void )
for( timer = ( SFG_Timer * )fgState.Timers.First;
timer;
timer = ( SFG_Timer * )timer->Node.Next )
ret = MIN( ret, MAX( 0, (timer->TriggerTime) - now ) );
ret = MIN( ret, MAX( 0, timer->TriggerTime - now ) );
return ret;
}
@ -466,7 +466,7 @@ static void fgSleepForEvents( void )
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
@ -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
@ -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 )
{
@ -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;
}
}
@ -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 =
@ -1170,6 +1171,13 @@ 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 ) )
@ -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
@ -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 )
@ -1722,7 +1744,6 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
/* User has clicked on the "-" to minimize the window */
/* Turn off the visibility */
window->State.Visible = GL_FALSE;
break;
case SC_MAXIMIZE:

View File

@ -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;
@ -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 );
/*
* Prepare the OpenGL state to do the rendering first:
*/
glPushAttrib( GL_DEPTH_BUFFER_BIT | GL_TEXTURE_BIT | GL_LIGHTING_BIT |
GL_POLYGON_BIT );
@ -465,9 +453,6 @@ 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( );
@ -477,26 +462,13 @@ void fgDisplayMenu( void )
-1, 1
);
/*
* Model-view matix gets reset to identity:
*/
glMatrixMode( GL_MODELVIEW );
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;
}
}
@ -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;