1 /**************************************************************************
4 * Written 1998 by Durk Talsma, started Juni, 1998. For the flight gear
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 * (Log is kept at end of this file)
23 **************************************************************************/
34 #include <Include/compiler.h>
39 #if defined(FX) && defined(XMESA)
40 # include <GL/xmesa.h>
48 #include <Include/general.hxx>
49 #include <Main/options.hxx>
56 puMenuBar *mainMenuBar;
57 puButton *hideMenuButton;
58 puDialogBox *dialogBox;
59 puText *dialogBoxMessage;
60 puOneShot *dialogBoxOkButton;
63 /* --------------------------------------------------------------------
65 ---------------------------------------------------------------------*/
67 void guiMotionFunc ( int x, int y )
70 glutPostRedisplay () ;
74 void guiMouseFunc(int button, int updown, int x, int y)
76 puMouse (button, updown, x,y);
80 /* -----------------------------------------------------------------------
81 the Gui callback functions
82 ____________________________________________________________________*/
84 void hideMenuCb (puObject *cb)
86 if (cb -> getValue () )
88 mainMenuBar -> reveal();
89 printf("Showing Menu");
90 hideMenuButton -> setLegend ("Hide Menu");
94 mainMenuBar -> hide ();
95 printf("Hiding Menu");
96 hideMenuButton -> setLegend ("Show Menu");
100 void goAwayCb (puObject *)
106 void mkDialog (char *txt)
108 dialogBox = new puDialogBox (150, 50);
110 new puFrame (0,0,400, 100);
111 dialogBoxMessage = new puText (10, 70);
112 dialogBoxMessage -> setLabel (txt);
113 dialogBoxOkButton = new puOneShot (180, 10, 240, 50);
114 dialogBoxOkButton -> setLegend ("OK");
115 dialogBoxOkButton -> makeReturnDefault (TRUE );
116 dialogBoxOkButton -> setCallback (goAwayCb);
118 dialogBox -> close();
119 dialogBox -> reveal();
122 void notCb (puObject *)
124 mkDialog ("This function isn't implemented yet");
127 void helpCb (puObject *)
129 #if defined(FX) && !defined(WIN32)
130 # if defined(XMESA_FX_FULLSCREEN) && defined(XMESA_FX_WINDOW)
131 if ( global_fullscreen ) {
132 global_fullscreen = false;
133 XMesaSetFXmode( XMESA_FX_WINDOW );
139 string url = "http://www.flightgear.org/Docs/InstallGuide/getstart.html";
142 if ( system("xwininfo -name Netscape > /dev/null 2>&1") == 0 ) {
143 command = "netscape -remote \"openURL(" + url + ")\" &";
145 command = "netscape " + url + " &";
148 system( command.c_str() );
149 string text = "Help started in netscape window.";
151 string text = "Help not yet implimented for Win32.";
154 mkDialog (text.c_str());
157 /* -----------------------------------------------------------------------
159 ---------------------------------------------------------------------*/
160 char *fileSubmenu [] = { "Exit", "Close", "---------", "Print", "---------", "Save", "New", NULL };
161 char *editSubmenu [] = { "Edit text", NULL };
162 char *viewSubmenu [] = { "Cockpit View > ", "View >","------------", "View options...", NULL };
163 char *aircraftSubmenu [] = { "Autopilot ...", "Engine ...", "Navigation", "Communication", NULL};
164 char *environmentSubmenu [] = { "Time & Date...", "Terrain ...", "Weather", NULL};
165 char *optionsSubmenu [] = { "Preferences", "Realism & Reliablity...", NULL};
166 char *helpSubmenu [] = { "About...", "Help", NULL };
168 puCallback fileSubmenuCb [] = { notCb, notCb, NULL, notCb, NULL, notCb, notCb, NULL};
169 puCallback editSubmenuCb [] = { notCb, NULL };
170 puCallback viewSubmenuCb [] = { notCb, notCb, NULL, notCb, NULL };
171 puCallback aircraftSubmenuCb [] = { notCb, notCb, notCb,notCb, NULL };
172 puCallback environmentSubmenuCb [] = { notCb, notCb, notCb, NULL };
173 puCallback optionsSubmenuCb [] = { notCb, notCb, NULL};
174 puCallback helpSubmenuCb [] = { notCb, helpCb, NULL };
178 /* -------------------------------------------------------------------------
180 _____________________________________________________________________*/
186 char *mesa_win_state;
191 if ( current_options.get_mouse_pointer() == 0 ) {
192 // no preference specified for mouse pointer, attempt to autodetect...
193 // Determine if we need to render the cursor, or if the windowing
194 // system will do it. First test if we are rendering with glide.
195 if ( strstr ( general.get_glRenderer(), "Glide" ) ) {
196 // Test for the MESA_GLX_FX env variable
197 if ( (mesa_win_state = getenv( "MESA_GLX_FX" )) != NULL) {
198 // test if we are fullscreen mesa/glide
199 if ( (mesa_win_state[0] == 'f') ||
200 (mesa_win_state[0] == 'F') ) {
205 } else if ( current_options.get_mouse_pointer() == 1 ) {
206 // don't show pointer
207 } else if ( current_options.get_mouse_pointer() == 2 ) {
208 // force showing pointer
212 // puSetDefaultStyle ( PUSTYLE_SMALL_BEVELLED );
213 puSetDefaultStyle ( PUSTYLE_DEFAULT );
214 puSetDefaultColourScheme (0.2, 0.4, 0.8, 0.5);
216 /* OK the rest is largerly put in here to mimick Steve Baker's
217 "complex" example It should change in future versions */
219 // timerText = new puText (300, 10);
220 // timerText -> setColour (PUCOL_LABEL, 1.0, 1.0, 1.0);
222 /* Make a button to hide the menu bar */
223 hideMenuButton = new puButton (10,10, 150, 50);
224 hideMenuButton -> setValue (TRUE);
225 hideMenuButton -> setLegend ("Hide Menu");
226 hideMenuButton -> setCallback (hideMenuCb);
227 hideMenuButton -> makeReturnDefault (TRUE);
228 hideMenuButton -> hide();
231 mainMenuBar = new puMenuBar ();
232 mainMenuBar -> add_submenu ("File", fileSubmenu, fileSubmenuCb);
233 mainMenuBar -> add_submenu ("Edit", editSubmenu, editSubmenuCb);
234 mainMenuBar -> add_submenu ("View", viewSubmenu, viewSubmenuCb);
235 mainMenuBar -> add_submenu ("Aircraft", aircraftSubmenu, aircraftSubmenuCb);
236 mainMenuBar -> add_submenu ("Environment", environmentSubmenu,
237 environmentSubmenuCb);
238 mainMenuBar -> add_submenu ("Options", optionsSubmenu, optionsSubmenuCb);
239 mainMenuBar -> add_submenu ("Help", helpSubmenu, helpSubmenuCb);
240 mainMenuBar-> close ();