]> git.mxchange.org Git - flightgear.git/commitdiff
GUI changes contributed by Norman Vine.
authorcurt <curt>
Wed, 12 May 1999 01:11:17 +0000 (01:11 +0000)
committercurt <curt>
Wed, 12 May 1999 01:11:17 +0000 (01:11 +0000)
Simulator/GUI/gui.cxx
Simulator/GUI/gui.h
Simulator/Main/GLUTkey.cxx
Simulator/Main/GLUTmain.cxx
Simulator/Main/Makefile.am

index c7a88c489eb16b11dc31523ec0e451ad8d2d2159..8f2be6c6ef3ea44237441989f2bb0b278fbd7c65 100644 (file)
 
 FG_USING_STD(string);
 
-static puMenuBar    *mainMenuBar;
-static puButton     *hideMenuButton;
-
-static puDialogBox  *dialogBox;
-static puFrame      *dialogFrame;
-static puText       *dialogBoxMessage;
-static puOneShot    *dialogBoxOkButton;
-
+// Pui hides low level access to the mouse and menu display states
+// so for now we track these in case we want to know about them
+puFont guiFnt = 0;               // Our High Level Gui Font
+fntTexFont *guiFntHandle = 0;    // lower level access to guiFnt's Font
+static int _mX = 0;              // current mouse x
+static int  _mY = 0;             //               y
+static int last_buttons = 0 ;    // mouse button state
+static int mouse_active = 0;     // is mouse displayed
+static int menu_on = 0;          //    menu  displayed
+
+
+// PUI objects
+static puMenuBar    *mainMenuBar = 0;
+//static puButton     *hideMenuButton = 0;
+
+static puDialogBox  *dialogBox = 0;
+static puFrame      *dialogFrame = 0;
+static puText       *dialogBoxMessage = 0;
+static puOneShot    *dialogBoxOkButton = 0;
+
+
+static puDialogBox  *YNdialogBox = 0;
+static puFrame      *YNdialogFrame = 0;
+static puText       *YNdialogBoxMessage = 0;
+static puOneShot    *YNdialogBoxOkButton = 0;
+static puOneShot    *YNdialogBoxNoButton = 0;
+
+// Accessor CallBacks for external PUI Objects
+extern void NewAltitude( puObject *cb );
+extern void NewHeading( puObject *cb );
 extern void fgAPAdjust( puObject * );
-// extern void fgLatLonFormatToggle( puObject *);
+extern void fgLatLonFormatToggle( puObject *);
+
 /* --------------------------------------------------------------------
 Mouse stuff
 ---------------------------------------------------------------------*/
-
-static int _mX = 0;
-static int  _mY = 0;
-static int last_buttons = 0 ;
-
 void guiMotionFunc ( int x, int y )
 {
     _mX = x;
@@ -95,10 +113,10 @@ void guiMouseFunc(int button, int updown, int x, int y)
     _mX = x;
     _mY = y;
     if ( updown == PU_DOWN )
-       last_buttons |=  ( 1 << button ) ;
+        last_buttons |=  ( 1 << button ) ;
     else
-       last_buttons &= ~( 1 << button ) ;
-       
+        last_buttons &= ~( 1 << button ) ;
+    
     puMouse (button, updown, x,y);
     glutPostRedisplay ();
 }
@@ -114,78 +132,152 @@ void guiGetMouse(int *x, int *y)
     *y = _mY;
 };
 
-/* -----------------------------------------------------------------------
-  the Gui callback functions 
-  ____________________________________________________________________*/
+static inline void TurnCursorOn( void )
+{
+    mouse_active = ~0;
+#if defined ( WIN32 ) || defined(__CYGWIN32__)
+    glutSetCursor(GLUT_CURSOR_INHERIT);
+#endif
+#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
+    glutWarpPointer( glutGet(GLUT_SCREEN_WIDTH)/2, glutGet(GLUT_SCREEN_HEIGHT)/2);
+#endif
+}
 
-void reInit(puObject *cb)
+static inline void TurnCursorOff( void )
 {
-    FGView *v = &current_view;
-    fgReInitSubsystems();
+    mouse_active = 0;
+#if defined ( WIN32 ) || defined(__CYGWIN32__)
+    glutSetCursor(GLUT_CURSOR_NONE);
+#else  // I guess this is what we want to do ??
+ #if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
+    glutWarpPointer( glutGet(GLUT_SCREEN_WIDTH), glutGet(GLUT_SCREEN_HEIGHT));
+ #endif
+#endif
+}
+
+// If the gui isn't active try to hide the mouse
+// an if the qui requested show the mouse
+// this can get confused if it rerequesting the gui object
+// should resync things.
+// see PUI macros in gui.hxx for normal use
+void maybeToggleMouse( void )
+{
+    static int first_time = ~0;
+    static int mouse_changed = 0;
+
+    if ( first_time ) {
+        if(!mouse_active) {
+            mouse_changed = ~mouse_changed;
+            TurnCursorOn();
+        }
+    } else {
+        if( mouse_changed ) {
+            mouse_changed = ~mouse_changed;
+            if(mouse_active) {
+                TurnCursorOff();
+            }
+        }
+    }
+    first_time = ~first_time;
+}
+
+// Call with FALSE to init and TRUE to restore
+void BusyCursor( int restore )
+{
+    static int cursor = 0;
+    if( restore ) {
+        glutSetCursor(cursor);
+    } else {
+        cursor = glutGet( GLUT_WINDOW_CURSOR );
+        TurnCursorOn();
+        glutSetCursor( GLUT_CURSOR_WAIT );
+    }
+}
+/* ================ General Purpose Functions ================ */
+
+// Intercept the Escape Key
+void ConfirmExitDialog(void)
+{
+    string Msg("Really Quit");
+    YNdialogBoxMessage -> setLabel(Msg.c_str());    
+    YNdialogBoxNoButton-> makeReturnDefault  (TRUE );
+    FG_PUSH_PUI_DIALOG( YNdialogBox );
+}
+
+// General Purpose Message Box
+void mkDialog (char *txt)
+{
+    void goAwayCb(puObject *);
+    dialogBoxMessage->setLabel(txt);
+    dialogBoxOkButton -> setLegend          ("OK");
+    dialogBoxOkButton -> makeReturnDefault  (TRUE );
+    dialogBoxOkButton -> setCallback        (goAwayCb);
+    FG_PUSH_PUI_DIALOG( dialogBox );
+}
+
+// Repair any damage done to the Panel by other Gui Items
+// see PUI macros in gui.hxx for use
+void guiFixPanel( void )
+{
+    int toggle_pause;
+    
     if ( current_options.get_panel_status() ) {
-       // this seems to be the only way to do this :-(
-       // problem is the viewport has been mucked with
-       //              current_options.toggle_panel();
-       //              current_options.toggle_panel();
-       xglViewport(0, 0 ,
-                   (GLint)(v->winWidth), (GLint)(v->winHeight) );
-       FGPanel::OurPanel->ReInit(0, 0, 1024, 768);
+        
+        FGView *v = &current_view;
+        FGTime *t = FGTime::cur_time_params;
+
+        if( (toggle_pause = !t->getPause()) )
+            t->togglePauseMode();
+    
+        // this seems to be the only way to do this :-(
+        // problem is the viewport has been mucked with
+        xglViewport(0, 0 , (GLint)(v->winWidth), (GLint)(v->winHeight) );
+        FGPanel::OurPanel->ReInit(0, 0, 1024, 768);
+        
+        if(toggle_pause)
+            t->togglePauseMode();
     }
 }
 
+// Toggle the Menu and Mouse display state
 void guiToggleMenu(void)
 {
-    hideMenuButton -> 
-       setValue ((int) !(hideMenuButton -> getValue() ) );
-    hideMenuButton -> invokeCallback();
+    if( menu_on ) {
+        // printf("Hiding Menu\n");
+        mainMenuBar->hide  ();
+        TurnCursorOff();
+    } else {
+        // printf("Showing Menu\n");
+        mainMenuBar->reveal();
+        TurnCursorOn();
+    }
+    menu_on = ~menu_on;
 }
-       
-void guiTogglePanel(puObject *cb)
+    
+/* -----------------------------------------------------------------------
+the Gui callback functions 
+____________________________________________________________________*/
+
+void reInit(puObject *cb)
 {
-    current_options.toggle_panel();
+    BusyCursor(0);
+    fgReInitSubsystems();
+    BusyCursor(1);
 }
        
-void MenuHideMenuCb(puObject *cb)
+// This is the accessor function
+void guiTogglePanel(puObject *cb)
 {
-    mainMenuBar -> hide  ();
-    // printf("Hiding Menu\n");
-    hideMenuButton -> setLegend ("Show Menu");
-#if defined ( WIN32 ) || defined(__CYGWIN32__)
-    glutSetCursor(GLUT_CURSOR_NONE);
-#else  // I guess this is what we want to do ??
-#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
-    glutWarpPointer( glutGet(GLUT_SCREEN_WIDTH), glutGet(GLUT_SCREEN_HEIGHT));
-#endif
-#endif
+    current_options.toggle_panel();
 }
-
+    
+//void MenuHideMenuCb(puObject *cb)
 void hideMenuCb (puObject *cb)
 {
-    if (cb -> getValue () ) {
-       mainMenuBar -> reveal();
-       // printf("Showing Menu\n");
-       hideMenuButton -> setLegend ("Hide Menu");
-#if defined ( WIN32 ) || defined(__CYGWIN32__)
-       glutSetCursor(GLUT_CURSOR_INHERIT);
-#else  // I guess this is what we want to do ??
-       glutWarpPointer( glutGet(GLUT_SCREEN_WIDTH)/2, 
-                        glutGet(GLUT_SCREEN_HEIGHT)/2 );
-#endif
-    } else{
-       mainMenuBar -> hide  ();
-       // printf("Hiding Menu\n");
-       hideMenuButton -> setLegend ("Show Menu");
-#if defined ( WIN32 ) || defined(__CYGWIN32__)
-       glutSetCursor(GLUT_CURSOR_NONE);
-#else  // I guess this is what we want to do ??
-#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
-       glutWarpPointer( glutGet(GLUT_SCREEN_WIDTH), 
-                        glutGet(GLUT_SCREEN_HEIGHT));
-#endif
-#endif
-    }
+    guiToggleMenu();
 }
 
+// This is the accessor function
 void goodBye(puObject *)
 {
     // FG_LOG( FG_INPUT, FG_ALERT, 
@@ -201,33 +293,56 @@ void goodBye(puObject *)
 
 void goAwayCb (puObject *me)
 {
-    delete dialogBoxOkButton;
-    dialogBoxOkButton = NULL;
-       
-    delete dialogBoxMessage;
-    dialogBoxMessage = NULL;
-       
-    delete dialogFrame;
-    dialogFrame = NULL;
-
-    delete dialogBox;
-    dialogBox = NULL;
+    FG_POP_PUI_DIALOG( dialogBox );
 }
 
-void mkDialog (const char *txt)
+void mkDialogInit (void)
 {
+//  printf("mkDialogInit\n");
     dialogBox = new puDialogBox (150, 50);
     {
-       dialogFrame = new puFrame (0,0,400, 100);
-       dialogBoxMessage  =  new puText         (10, 70);
-       dialogBoxMessage  -> setLabel           (txt);
-       dialogBoxOkButton =  new puOneShot      (180, 10, 240, 50);
-       dialogBoxOkButton -> setLegend          ("OK");
-       dialogBoxOkButton -> makeReturnDefault  (TRUE );
-       dialogBoxOkButton -> setCallback        (goAwayCb);
+        dialogFrame = new puFrame (0,0,400, 100);
+        dialogBoxMessage  =  new puText         (10, 70);
+        dialogBoxMessage  -> setLabel           ("");
+        dialogBoxOkButton =  new puOneShot      (180, 10, 240, 50);
     }
-    dialogBox -> close();
-    dialogBox -> reveal();
+    FG_FINALIZE_PUI_DIALOG( dialogBox );
+}
+
+void MayBeGoodBye(puObject *)
+{
+    ConfirmExitDialog(); 
+}
+
+void goAwayYesNoCb(puObject *me)
+{
+    FG_POP_PUI_DIALOG( YNdialogBox);
+}
+
+void ConfirmExitDialogInit(void)
+{
+//  printf("ConfirmExitDialogInit\n");
+    string Msg("Really Quit");
+//  int len = 350/2 - puGetStringWidth( puGetDefaultLabelFont(), AptLabel )/2;
+    int len = 200 - puGetStringWidth( puGetDefaultLabelFont(), Msg.c_str() )/2;
+    
+    YNdialogBox = new puDialogBox (150, 50);
+    {
+        YNdialogFrame = new puFrame (0,0,400, 100);
+        
+        YNdialogBoxMessage  =  new puText         (len, 70);
+        YNdialogBoxMessage  -> setLabel           (Msg.c_str());
+        
+        YNdialogBoxOkButton =  new puOneShot      (100, 10, 160, 50);
+        YNdialogBoxOkButton -> setLegend          ("OK");
+        YNdialogBoxOkButton -> setCallback        (goodBye);
+        
+        YNdialogBoxNoButton =  new puOneShot      (240, 10, 300, 50);
+        YNdialogBoxNoButton -> setLegend          ("NO");
+//      YNdialogBoxNoButton -> makeReturnDefault  (TRUE );
+        YNdialogBoxNoButton -> setCallback        (goAwayYesNoCb);
+    }
+    FG_FINALIZE_PUI_DIALOG( YNdialogBox );
 }
 
 void notCb (puObject *)
@@ -242,8 +357,8 @@ void helpCb (puObject *)
 #if defined(FX) && !defined(WIN32)
 #  if defined(XMESA_FX_FULLSCREEN) && defined(XMESA_FX_WINDOW)
     if ( global_fullscreen ) {
-       global_fullscreen = false;
-       XMesaSetFXmode( XMESA_FX_WINDOW );
+        global_fullscreen = false;
+        XMesaSetFXmode( XMESA_FX_WINDOW );
     }
 #  endif
 #endif
@@ -269,156 +384,110 @@ void helpCb (puObject *)
 /// The beginnings of teleportation :-)
 //  Needs cleaning up but works
 //  These statics should disapear when this is a class
-static puDialogBox     *AptDialog;
-static puFrame         *AptDialogFrame;
-static puText          *AptDialogMessage;
-static puInput         *AptDialogInput;
+static puDialogBox     *AptDialog = 0;
+static puFrame         *AptDialogFrame = 0;
+static puText          *AptDialogMessage = 0;
+static puInput         *AptDialogInput = 0;
 
-static puOneShot       *AptDialogOkButton;
-static puOneShot       *AptDialogCancelButton;
-static puOneShot       *AptDialogResetButton;
+static puOneShot       *AptDialogOkButton = 0;
+static puOneShot       *AptDialogCancelButton = 0;
+static puOneShot       *AptDialogResetButton = 0;
 
-static string AptDialog_OldAptId;
-static string AptDialog_NewAptId;
-static int    AptDialog_ValidAptId;
-
-static void validateApt (puObject *inpApt)
+void AptDialog_Cancel(puObject *)
 {
-    char *s;
-    AptDialog_ValidAptId = 0;
-
-    inpApt->getValue(&s);
-
-    AptDialog_NewAptId = s;
-
-    if ( AptDialog_NewAptId.length() ) {
-       // set initial position from airport id
-
-       fgAIRPORTS airports;
-       fgAIRPORT a;
-
-       FG_LOG( FG_GENERAL, FG_INFO, 
-               "Attempting to set starting position from airport code "
-               << s );
-
-       airports.load("apt_simple");
-       if ( ! airports.search( AptDialog_NewAptId, &a ) ) {
-           string err_string = "Failed to find ";
-           err_string += s;
-           err_string += " in database.";
-           mkDialog(err_string.c_str());
-           FG_LOG( FG_GENERAL, FG_ALERT,
-                   "Failed to find " << s << " in database." );
-       } else {
-           AptDialog_ValidAptId = 1;
-           AptDialog_OldAptId = s;
-           current_options.set_airport_id(AptDialog_NewAptId);
-       }
-    }
-       
-    if( AptDialog_ValidAptId ) {
-       fgReInitSubsystems();
-    }
+    AptDialogOkButton->makeReturnDefault(FALSE);
+    AptDialogInput->rejectInput();
+    FG_POP_PUI_DIALOG( AptDialog );
 }
 
-void AptDialog_Cancel(puObject *)
+void AptDialog_OK (puObject *)
 {
+    string AptId;
+    
     FGTime *t = FGTime::cur_time_params;
-    FGView *v = &current_view;
-       
-    if ( current_options.get_panel_status() ) {
-       // this seems to be the only way to do this :-(
-       // problem is the viewport has been mucked with
-       //              current_options.toggle_panel();
-       //              current_options.toggle_panel();
-       xglViewport(0, 0 ,
-                   (GLint)(v->winWidth), (GLint)(v->winHeight) );
-       FGPanel::OurPanel->ReInit(0, 0, 1024, 768);
-    }
-
-    delete AptDialogResetButton;
-    AptDialogResetButton = NULL;
-
-    delete AptDialogCancelButton;
-    AptDialogCancelButton = NULL;
-
-    delete AptDialogOkButton;
-    AptDialogOkButton = NULL;
-
-    delete AptDialogInput;
-    AptDialogInput = NULL;
-
-    delete AptDialogMessage;
-    AptDialogMessage = NULL;
+    int PauseMode = t->getPause();
+    if(!PauseMode)
+        t->togglePauseMode();
 
-    delete AptDialogFrame;
-    AptDialogFrame = NULL;
-
-    delete AptDialog;
-    AptDialog = NULL;
-       
-    t->togglePauseMode();
-}
-
-void AptDialog_OK (puObject *me)
-{
-    validateApt(AptDialogInput);
-    AptDialog_Cancel(me);
+    char *s;
+    AptDialogInput->getValue(&s);
+    AptId = s;
+    
+    AptDialog_Cancel( NULL );
+    
+    if ( AptId.length() ) {
+        // set initial position from airport id
+        
+        fgAIRPORTS airports;
+        fgAIRPORT a;
+        
+        FG_LOG( FG_GENERAL, FG_INFO,
+                "Attempting to set starting position from airport code "
+                << s );
+        
+        airports.load("apt_simple");
+        if ( airports.search( AptId, &a ) )
+        {
+            current_options.set_airport_id( AptId.c_str() );
+            BusyCursor(0);
+            fgReInitSubsystems();
+            BusyCursor(1);
+        } else {
+            AptId  += " not in database.";
+            mkDialog(AptId.c_str());
+        }
+    }
+    if( PauseMode != t->getPause() )
+        t->togglePauseMode();
 }
 
 void AptDialog_Reset(puObject *)
 {
-    AptDialogInput->setValue ( AptDialog_OldAptId.c_str() );
+    AptDialogInput->setValue ( current_options.get_airport_id().c_str() );
     AptDialogInput->setCursor( 0 ) ;
 }
 
-void NewAirportInit(puObject *cb)
+
+// This is the accessor function
+void NewAirport(puObject *cb)
 {
-    FGInterface *f;
-    FGTime *t;
-       
-    f = current_aircraft.fdm_state;
-    t = FGTime::cur_time_params;
-       
-    char *AptLabel = "Enter New Airport ID";
-    int len = 350/2 - puGetStringWidth(NULL, AptLabel)/2;
+    string AptLabel("Enter New Airport ID");
+    AptDialogMessage ->setLabel( AptLabel.c_str() );
+    AptDialogInput   ->setValue( current_options.get_airport_id().c_str() );
+    AptDialogInput   ->acceptInput();
+    AptDialogOkButton->makeReturnDefault(TRUE);
+    
+    FG_PUSH_PUI_DIALOG( AptDialog );
+}
 
-    AptDialog_OldAptId = current_options.get_airport_id();
-    char *s            = AptDialog_OldAptId.c_str();
+static void NewAirportInit(void)
+{
+    cout << "NewAirportInit" << endl;
 
+    string AptLabel("Enter New Airport ID");
+//  int len = 350/2 - puGetStringWidth( puGetDefaultLabelFont(), AptLabel )/2;
+    int len = 150 - puGetStringWidth( puGetDefaultLabelFont(), AptLabel.c_str() )/2;
+    
     AptDialog = new puDialogBox (150, 50);
     {
-       AptDialogFrame   = new puFrame           (0,0,350, 150);
-       AptDialogMessage = new puText            (len, 110);
-       AptDialogMessage ->    setLabel          (AptLabel);
-
-       AptDialogInput   = new puInput           ( 50, 70, 300, 100 );
-       AptDialogInput   ->    setValue          ( s );
-       // Uncomment the next line to have input active on startup
-       AptDialogInput   ->    acceptInput       ( );
-       // cursor at begining or end of line ?
-       //len = strlen(s);
-       len = 0;
-       AptDialogInput   ->    setCursor         ( len );
-       AptDialogInput   ->    setSelectRegion   ( 5, 9 );
-               
-       AptDialogOkButton     =  new puOneShot         (50, 10, 110, 50);
-       AptDialogOkButton     ->     setLegend         ("OK");
-       AptDialogOkButton     ->     makeReturnDefault (TRUE );
-       AptDialogOkButton     ->     setCallback       (AptDialog_OK);
-               
-       AptDialogCancelButton =  new puOneShot         (140, 10, 210, 50);
-       AptDialogCancelButton ->     setLegend         ("Cancel");
-       AptDialogCancelButton ->     makeReturnDefault (TRUE );
-       AptDialogCancelButton ->     setCallback       (AptDialog_Cancel);
-               
-       AptDialogResetButton  =  new puOneShot         (240, 10, 300, 50);
-       AptDialogResetButton  ->     setLegend         ("Reset");
-       AptDialogResetButton  ->     makeReturnDefault (TRUE );
-       AptDialogResetButton  ->     setCallback       (AptDialog_Reset);
+        AptDialogFrame   = new puFrame           (0,0,350, 150);
+        AptDialogMessage = new puText            (len, 110);
+        
+        AptDialogInput   = new puInput           ( 50, 70, 300, 100 );
+        
+        AptDialogOkButton     =  new puOneShot   (50, 10, 110, 50);
+        AptDialogOkButton     ->     setLegend   ("OK");
+        AptDialogOkButton     ->     setCallback (AptDialog_OK);
+        
+        AptDialogCancelButton =  new puOneShot   (140, 10, 210, 50);
+        AptDialogCancelButton ->     setLegend   ("Cancel");
+        AptDialogCancelButton ->     setCallback (AptDialog_Cancel);
+        
+        AptDialogResetButton  =  new puOneShot   (240, 10, 300, 50);
+        AptDialogResetButton  ->     setLegend   ("Reset");
+        AptDialogResetButton  ->     setCallback (AptDialog_Reset);
     }
-    AptDialog -> close();
-    AptDialog -> reveal();
+    FG_FINALIZE_PUI_DIALOG( AptDialog );
 }
 
 
@@ -428,27 +497,27 @@ void NewAirportInit(puObject *cb)
 char *fileSubmenu               [] = {
     "Exit", "Close", "---------", "Print", "---------", "Save", "Reset", NULL };
 puCallback fileSubmenuCb        [] = {
-    goodBye, MenuHideMenuCb, NULL, notCb, NULL, notCb, reInit, NULL};
-       
+    MayBeGoodBye, hideMenuCb, NULL, notCb, NULL, notCb, reInit, NULL};  
+    
 char *editSubmenu               [] = {
     "Edit text", NULL };
 puCallback editSubmenuCb        [] = {
     notCb, NULL };
-       
+
 char *viewSubmenu               [] = {
     "Cockpit View > ", "View >","------------", "Toggle Panel...", NULL };
 puCallback viewSubmenuCb        [] = {
     notCb, notCb, NULL, guiTogglePanel, NULL };
        
 char *aircraftSubmenu           [] = {
-    "Autopilot ...", "Engine ...", "Navigation", "Communication", NULL};
+    "Autopilot", "Heading", "Altitude", "Navigation", "Communication", NULL};
 puCallback aircraftSubmenuCb    [] = {
-    fgAPAdjust, notCb, notCb, notCb, NULL };
+    fgAPAdjust, NewHeading, NewAltitude, fgLatLonFormatToggle, notCb, NULL };
 
 char *environmentSubmenu        [] = {
     "Airport", "Terrain", "Weather", NULL};
 puCallback environmentSubmenuCb [] = {
-    NewAirportInit, notCb, notCb, NULL };
+    NewAirport, notCb, notCb, NULL };
 
 char *optionsSubmenu            [] = {
     "Preferences", "Realism & Reliablity...", NULL};
@@ -473,52 +542,56 @@ void guiInit()
 
     // Initialize PUI
     puInit();
+    puSetDefaultStyle         ( PUSTYLE_DEFAULT );
+    puSetDefaultColourScheme  (0.8, 0.8, 0.8, 0.4);
 
+    // Install our fast fonts
+    string fntpath = current_options.get_fg_root() + "/Fonts/" + 
+        "typewriter" + ".txf";
+    guiFntHandle = new fntTexFont ;
+    guiFntHandle -> load ( fntpath.c_str() ) ;
+    puFont GuiFont ( guiFntHandle, 15 ) ;
+    puSetDefaultFonts( GuiFont, GuiFont ) ;
+    guiFnt = puGetDefaultLabelFont();
+  
     if ( current_options.get_mouse_pointer() == 0 ) {
-       // no preference specified for mouse pointer, attempt to autodetect...
-       // Determine if we need to render the cursor, or if the windowing
-       // system will do it.  First test if we are rendering with glide.
-       if ( strstr ( general.get_glRenderer(), "Glide" ) ) {
-           // Test for the MESA_GLX_FX env variable
-           if ( (mesa_win_state = getenv( "MESA_GLX_FX" )) != NULL) {
-               // test if we are fullscreen mesa/glide
-               if ( (mesa_win_state[0] == 'f') ||
-                    (mesa_win_state[0] == 'F') ) {
-                   puShowCursor ();
-               }
-           }
-       }
+        // no preference specified for mouse pointer, attempt to autodetect...
+        // Determine if we need to render the cursor, or if the windowing
+        // system will do it.  First test if we are rendering with glide.
+        if ( strstr ( general.get_glRenderer(), "Glide" ) ) {
+            // Test for the MESA_GLX_FX env variable
+            if ( (mesa_win_state = getenv( "MESA_GLX_FX" )) != NULL) {
+                // test if we are fullscreen mesa/glide
+                if ( (mesa_win_state[0] == 'f') ||
+                     (mesa_win_state[0] == 'F') ) {
+                    puShowCursor ();
+                }
+            }
+        }
+        mouse_active = ~mouse_active;
     } else if ( current_options.get_mouse_pointer() == 1 ) {
-       // don't show pointer
+        // don't show pointer
     } else if ( current_options.get_mouse_pointer() == 2 ) {
-       // force showing pointer
-       puShowCursor();
+        // force showing pointer
+        puShowCursor();
+        mouse_active = ~mouse_active;
     }
 
-    // puSetDefaultStyle         ( PUSTYLE_SMALL_BEVELLED );
-    puSetDefaultStyle         ( PUSTYLE_DEFAULT );
-    //    puSetDefaultColourScheme  (0.2, 0.4, 0.8, 0.5);
-    puSetDefaultColourScheme  (0.8, 0.8, 0.8, 0.4);
-    /* OK the rest is largely put in here to mimick Steve Baker's
-       "complex" example It should change in future versions */
-
-    /* Make a button to hide the menu bar */
-    hideMenuButton = new puButton       (10,10, 150, 50);
-    hideMenuButton -> setValue          (TRUE);
-    hideMenuButton -> setLegend         ("Hide Menu");
-    hideMenuButton -> setCallback       (hideMenuCb);
-    hideMenuButton -> makeReturnDefault (TRUE);
-    hideMenuButton -> hide();
-
+    // Set up our Dialog Boxes
+    ConfirmExitDialogInit();
+    NewAirportInit();
+    mkDialogInit();
+    
     // Make the menu bar
     mainMenuBar = new puMenuBar ();
     mainMenuBar -> add_submenu ("File", fileSubmenu, fileSubmenuCb);
     mainMenuBar -> add_submenu ("Edit", editSubmenu, editSubmenuCb);
     mainMenuBar -> add_submenu ("View", viewSubmenu, viewSubmenuCb);
     mainMenuBar -> add_submenu ("Aircraft", aircraftSubmenu, aircraftSubmenuCb);
-    mainMenuBar -> add_submenu ("Environment", environmentSubmenu,
-                               environmentSubmenuCb);
+    mainMenuBar -> add_submenu ("Environment", environmentSubmenu, environmentSubmenuCb);
     mainMenuBar -> add_submenu ("Options", optionsSubmenu, optionsSubmenuCb);
     mainMenuBar -> add_submenu ("Help", helpSubmenu, helpSubmenuCb);
     mainMenuBar-> close ();
+    // Set up menu bar toggle
+    menu_on = ~0;
 }
index f5e6326b067cffb9daa9b2aca654f0221578ec48..e2fc514e5d2f8799329c566a2bfac5b06357a982 100644 (file)
 
 #include <plib/pu.h>
 
+extern void guiInit();
 extern void guiMotionFunc ( int x, int y );
 extern void guiMouseFunc(int button, int updown, int x, int y);
-extern void guiInit();
+extern void maybeToggleMouse( void );
+extern void BusyCursor( int restore );
+
 extern void guiToggleMenu(void);
-void mkDialog (const char *txt);
+extern void mkDialog(char *txt);
+extern void ConfirmExitDialog(void);
+extern void guiFixPanel( void );
+
+extern puFont guiFnt;
+extern fntTexFont *guiFntHandle;
+
+
+// MACROS TO HELP KEEP PUI LIVE INTERFACE STACK IN SYNC
+// These insure that the mouse is active when dialog is shown
+// and try to the maintain the original mouse state when hidden
+// These will also repair any damage done to the Panel if active
+
+// Activate Dialog Box
+#define FG_PUSH_PUI_DIALOG( X ) \
+    maybeToggleMouse(); \
+    puPushGroup( (X) ) ; \
+    puPushLiveInterface( (X) ) ; \
+    ( X )->reveal()
+
+// Deactivate Dialog Box
+#define FG_POP_PUI_DIALOG( X ) \
+    (X)->hide(); \
+    puPopLiveInterface(); \
+    puPopGroup(); \
+    guiFixPanel(); \
+    maybeToggleMouse();
 
+// Finalize Dialog Box Construction 
+#define FG_FINALIZE_PUI_DIALOG( X ) \
+    ( X )->close(); \
+    ( X )->hide(); \
+    puPopLiveInterface();
+            
 #endif // _GUI_H_
index ba09d610b563f7a23c1e47f622c3f20088d238fd..5b8e608c7fc8bfdcf5068203a0aaa8a0e3297e7b 100644 (file)
@@ -56,6 +56,8 @@
 #include "options.hxx"
 #include "views.hxx"
 
+extern void NewAltitude( puObject *cb );
+extern void NewHeading( puObject *cb );
 
 // Force an update of the sky and lighting parameters
 static void local_update_sky_and_lighting_params( void ) {
@@ -136,7 +138,7 @@ void GLUTkey(unsigned char k, int x, int y) {
            // current_options.set_hud_status(!status);
            HUD_brightkey( true );
            return;
-       case 73: // i key
+       case 73: // I key
            // Minimal Hud
            fgHUDInit2(&current_aircraft);
            return;
@@ -145,8 +147,8 @@ void GLUTkey(unsigned char k, int x, int y) {
            local_update_sky_and_lighting_params();
            return;
        case 80: // P key
-               current_options.toggle_panel();
-               break;
+           current_options.toggle_panel();
+           break;
        case 84: // T key
            t->adjust_warp_delta(-30);
            local_update_sky_and_lighting_params();
@@ -290,7 +292,8 @@ void GLUTkey(unsigned char k, int x, int y) {
            // }
            FG_LOG( FG_INPUT, FG_ALERT, 
                    "Program exiting normally at user request." );
-           exit(-1);
+           ConfirmExitDialog();
+           return;
        }
     }
 }
@@ -368,8 +371,16 @@ void GLUTspecialkey(int k, int x, int y) {
        case GLUT_KEY_F10: // F10 toggles menu on and off...
            FG_LOG(FG_INPUT, FG_INFO, "Invoking call back function");
            guiToggleMenu();
+           return;
+       case GLUT_KEY_F11: // F11 Altitude Dialog.
+           FG_LOG(FG_INPUT, FG_INFO, "Invoking Altitude call back function");
+           NewAltitude( NULL );
            //exit(1);
            return;
+       case GLUT_KEY_F12: // F12 Heading Dialog...
+           FG_LOG(FG_INPUT, FG_INFO, "Invoking Heading call back function");
+           NewHeading( NULL );
+           return;
        case GLUT_KEY_UP:
            if( fgAPAltitudeEnabled() || fgAPTerrainFollowEnabled() ) {
                fgAPAltitudeAdjust( -100 );
index 7e037d4c0bb8a76d625fdeb39afdb0414091c83c..8d50b2c376fc1132a1381e12276cd74e82831e28 100644 (file)
@@ -283,7 +283,7 @@ static void fgRenderFrame( void ) {
                // glClearColor(black[0], black[1], black[2], black[3]);
                glClearColor(l->adj_fog_color[0], l->adj_fog_color[1], 
                             l->adj_fog_color[2], l->adj_fog_color[3]);
-               clear_mask |= GL_COLOR_BUFFER_BIT;              
+               clear_mask |= GL_COLOR_BUFFER_BIT;
            }
        } else {
            glClearColor(l->sky_color[0], l->sky_color[1], 
@@ -394,10 +394,10 @@ void fgUpdateTimeDepCalcs(int multi_loop, int remainder) {
 
        // printf("updating flight model x %d\n", multi_loop);
        fgFDMUpdate( current_options.get_flight_model(), 
-                            cur_fdm_state, multi_loop, remainder );
+                    cur_fdm_state, multi_loop, remainder );
     } else {
        fgFDMUpdate( current_options.get_flight_model(), 
-                            cur_fdm_state, 0, remainder );
+                    cur_fdm_state, 0, remainder );
     }
 
     // update the view angle
@@ -1000,7 +1000,7 @@ int main( int argc, char **argv ) {
     // Parse remaining command line options
     // These will override anything specified in a config file
     if ( current_options.parse_command_line(argc, argv) !=
-                                     fgOPTIONS::FG_OPTIONS_OK )
+        fgOPTIONS::FG_OPTIONS_OK )
     {
        // Something must have gone horribly wrong with the command
        // line parsing or maybe the user just requested help ... :-)
@@ -1022,6 +1022,10 @@ int main( int argc, char **argv ) {
        exit(-1);
     }
 
+    // Init the user interface (we need to do this before passing off
+    // control to glut and before fgInitGeneral to get our fonts !!!
+    guiInit();
+
     // First do some quick general initializations
     if( !fgInitGeneral()) {
        FG_LOG( FG_GENERAL, FG_ALERT, 
@@ -1029,10 +1033,6 @@ int main( int argc, char **argv ) {
        exit(-1);
     }
 
-    // Init the user interface (we need to do this before passing off
-    // control to glut
-    guiInit();
-
     // pass control off to the master GLUT event handler
     glutMainLoop();
 
index 96d2c6634cc624731b933b9a9a74d33b7b1ff7be..e857a51a7b6ddf63057bf57935b91ead0b505002 100644 (file)
@@ -64,7 +64,7 @@ fgfs_LDADD = \
        $(top_builddir)/Lib/Math/libMath.a \
        $(top_builddir)/Lib/Bucket/libBucket.a \
        $(top_builddir)/Lib/Debug/libDebug.a \
-       -L$(top_builddir)/Lib/plib/src/pui -lpu \
+       -lpu -lfnt \
        $(top_builddir)/Lib/zlib/libz.a \
        $(top_builddir)/Lib/Misc/libMisc.a \
        $(opengl_LIBS)