X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Ffreeglut_menu.c;h=ea5837e807d3aff8115170ca7e1079565437f349;hb=ded8742fba5a4622b49778679cc7e26d197d75c5;hp=871c1ba6bdd23ad32e6795c2806cdb232366aa59;hpb=27b65994dff98f0598e4fdc34d5e0063b542173b;p=freeglut diff --git a/src/freeglut_menu.c b/src/freeglut_menu.c index 871c1ba..ea5837e 100644 --- a/src/freeglut_menu.c +++ b/src/freeglut_menu.c @@ -25,6 +25,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#define FREEGLUT_BUILDING_LIB #include #include "freeglut_internal.h" @@ -52,7 +53,7 @@ * that that wasn't the original intent...if not, perhaps we need another * symbolic constant, FREEGLUT_MENU_ITEM_BORDER, or such.) */ -#if TARGET_HOST_WIN32 || TARGET_HOST_WINCE +#if TARGET_HOST_MS_WINDOWS #define FREEGLUT_MENU_FONT GLUT_BITMAP_8_BY_13 #else #define FREEGLUT_MENU_FONT GLUT_BITMAP_HELVETICA_18 @@ -71,7 +72,7 @@ * too. These variables should be stuffed into global state and initialized * via the glutInit*() system. */ -#if TARGET_HOST_WIN32 || TARGET_HOST_WINCE +#if TARGET_HOST_MS_WINDOWS static float menu_pen_fore [4] = {0.0f, 0.0f, 0.0f, 1.0f}; static float menu_pen_back [4] = {0.85f, 0.85f, 0.85f, 1.0f}; static float menu_pen_hfore [4] = {1.0f, 1.0f, 1.0f, 1.0f}; @@ -110,7 +111,6 @@ static SFG_MenuEntry *fghFindMenuEntry( SFG_Menu* menu, int index ) */ static void fghDeactivateSubMenu( SFG_MenuEntry *menuEntry ) { - SFG_Window *current_window = fgStructure.CurrentWindow; SFG_MenuEntry *subMenuIter; /* Hide the present menu's window */ fgSetWindow( menuEntry->SubMenu->Window ); @@ -141,9 +141,9 @@ static void fghDeactivateSubMenu( SFG_MenuEntry *menuEntry ) */ static GLvoid fghGetVMaxExtent( SFG_Window* window, int* x, int* y ) { - if( fgStructure.GameMode ) + if( fgStructure.GameModeWindow ) { -#if TARGET_HOST_UNIX_X11 +#if TARGET_HOST_POSIX_X11 int wx, wy; Window w; @@ -264,9 +264,13 @@ static GLboolean fghCheckMenuStatus( SFG_Menu* menu ) menuEntry->SubMenu->X = menu->X - menuEntry->SubMenu->Width; if( menuEntry->SubMenu->Y + menuEntry->SubMenu->Height > max_y ) + { menuEntry->SubMenu->Y -= ( menuEntry->SubMenu->Height - FREEGLUT_MENU_HEIGHT - 2 * FREEGLUT_MENU_BORDER ); + if( menuEntry->SubMenu->Y < 0 ) + menuEntry->SubMenu->Y = 0; + } fgSetWindow( menuEntry->SubMenu->Window ); glutPositionWindow( menuEntry->SubMenu->X, @@ -553,7 +557,11 @@ static void fghActivateMenu( SFG_Window* window, int button ) menu->X -=menu->Width; if( menu->Y + menu->Height > max_y ) + { menu->Y -=menu->Height; + if( menu->Y < 0 ) + menu->Y = 0; + } menu->Window->State.MouseX = window->State.MouseX + glutGet( GLUT_WINDOW_X ) - menu->X; @@ -675,7 +683,6 @@ GLboolean fgCheckActiveMenu ( SFG_Window *window, int button, GLboolean pressed, */ void fgDeactivateMenu( SFG_Window *window ) { - SFG_Window *current_window = fgStructure.CurrentWindow; SFG_Window *parent_window = NULL; /* Check if there is an active menu attached to this window... */ @@ -772,6 +779,14 @@ int FGAPIENTRY glutCreateMenu( void(* callback)( int ) ) return fgCreateMenu( callback )->ID; } +#if TARGET_HOST_MS_WINDOWS +int FGAPIENTRY __glutCreateMenuWithExit( void(* callback)( int ), void (__cdecl *exit_function)(int) ) +{ + __glutExitFunc = exit_function; + return glutCreateMenu( callback ); +} +#endif + /* * Destroys a menu object, removing all references to it */