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 **************************************************************************/
33 #include <Include/compiler.h>
38 #if defined(FX) && defined(XMESA)
39 # include <GL/xmesa.h>
47 #include <Include/general.hxx>
48 #include <Main/options.hxx>
55 puMenuBar *mainMenuBar;
56 puButton *hideMenuButton;
57 puDialogBox *dialogBox;
58 puText *dialogBoxMessage;
59 puOneShot *dialogBoxOkButton;
62 /* --------------------------------------------------------------------
64 ---------------------------------------------------------------------*/
66 void guiMotionFunc ( int x, int y )
69 glutPostRedisplay () ;
73 void guiMouseFunc(int button, int updown, int x, int y)
75 puMouse (button, updown, x,y);
79 /* -----------------------------------------------------------------------
80 the Gui callback functions
81 ____________________________________________________________________*/
83 void hideMenuCb (puObject *cb)
85 if (cb -> getValue () )
87 mainMenuBar -> reveal();
88 printf("Showing Menu");
89 hideMenuButton -> setLegend ("Hide Menu");
93 mainMenuBar -> hide ();
94 printf("Hiding Menu");
95 hideMenuButton -> setLegend ("Show Menu");
99 void goAwayCb (puObject *)
105 void mkDialog (char *txt)
107 dialogBox = new puDialogBox (150, 50);
109 new puFrame (0,0,400, 100);
110 dialogBoxMessage = new puText (10, 70);
111 dialogBoxMessage -> setLabel (txt);
112 dialogBoxOkButton = new puOneShot (180, 10, 240, 50);
113 dialogBoxOkButton -> setLegend ("OK");
114 dialogBoxOkButton -> makeReturnDefault (TRUE );
115 dialogBoxOkButton -> setCallback (goAwayCb);
117 dialogBox -> close();
118 dialogBox -> reveal();
121 void notCb (puObject *)
123 mkDialog ("This function isn't implemented yet");
126 void helpCb (puObject *)
128 #if defined(FX) && !defined(WIN32)
129 # if defined(XMESA_FX_FULLSCREEN) && defined(XMESA_FX_WINDOW)
130 if ( global_fullscreen ) {
131 global_fullscreen = false;
132 XMesaSetFXmode( XMESA_FX_WINDOW );
138 string url = "http://www.flightgear.org/Docs/InstallGuide/getstart.html";
141 if ( system("xwininfo -name Netscape > /dev/null 2>&1") == 0 ) {
142 command = "netscape -remote \"openURL(" + url + ")\" &";
144 command = "netscape " + url + " &";
147 system( command.c_str() );
148 string text = "Help started in netscape window.";
150 string text = "Help not yet implimented for Win32.";
153 mkDialog ( (char*)text.c_str() );
156 /* -----------------------------------------------------------------------
158 ---------------------------------------------------------------------*/
159 char *fileSubmenu [] = { "Exit", "Close", "---------", "Print", "---------", "Save", "New", NULL };
160 char *editSubmenu [] = { "Edit text", NULL };
161 char *viewSubmenu [] = { "Cockpit View > ", "View >","------------", "View options...", NULL };
162 char *aircraftSubmenu [] = { "Autopilot ...", "Engine ...", "Navigation", "Communication", NULL};
163 char *environmentSubmenu [] = { "Time & Date...", "Terrain ...", "Weather", NULL};
164 char *optionsSubmenu [] = { "Preferences", "Realism & Reliablity...", NULL};
165 char *helpSubmenu [] = { "About...", "Help", NULL };
167 puCallback fileSubmenuCb [] = { notCb, notCb, NULL, notCb, NULL, notCb, notCb, NULL};
168 puCallback editSubmenuCb [] = { notCb, NULL };
169 puCallback viewSubmenuCb [] = { notCb, notCb, NULL, notCb, NULL };
170 puCallback aircraftSubmenuCb [] = { notCb, notCb, notCb,notCb, NULL };
171 puCallback environmentSubmenuCb [] = { notCb, notCb, notCb, NULL };
172 puCallback optionsSubmenuCb [] = { notCb, notCb, NULL};
173 puCallback helpSubmenuCb [] = { notCb, helpCb, NULL };
177 /* -------------------------------------------------------------------------
179 _____________________________________________________________________*/
185 char *mesa_win_state;
190 if ( current_options.get_mouse_pointer() == 0 ) {
191 // no preference specified for mouse pointer, attempt to autodetect...
192 // Determine if we need to render the cursor, or if the windowing
193 // system will do it. First test if we are rendering with glide.
194 if ( strstr ( general.get_glRenderer(), "Glide" ) ) {
195 // Test for the MESA_GLX_FX env variable
196 if ( (mesa_win_state = getenv( "MESA_GLX_FX" )) != NULL) {
197 // test if we are fullscreen mesa/glide
198 if ( (mesa_win_state[0] == 'f') ||
199 (mesa_win_state[0] == 'F') ) {
204 } else if ( current_options.get_mouse_pointer() == 1 ) {
205 // don't show pointer
206 } else if ( current_options.get_mouse_pointer() == 2 ) {
207 // force showing pointer
211 // puSetDefaultStyle ( PUSTYLE_SMALL_BEVELLED );
212 puSetDefaultStyle ( PUSTYLE_DEFAULT );
213 // puSetDefaultColourScheme (0.2, 0.4, 0.8, 0.5);
214 puSetDefaultColourScheme (0.8, 0.8, 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 ();