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 **************************************************************************/
29 #include <Include/general.hxx>
30 #include <Main/options.hxx>
35 puMenuBar *mainMenuBar;
36 puButton *hideMenuButton;
37 puDialogBox *dialogBox;
38 puText *dialogBoxMessage;
39 puOneShot *dialogBoxOkButton;
42 /* --------------------------------------------------------------------
44 ---------------------------------------------------------------------*/
46 void guiMotionFunc ( int x, int y )
49 glutPostRedisplay () ;
53 void guiMouseFunc(int button, int updown, int x, int y)
55 puMouse (button, updown, x,y);
59 /* -----------------------------------------------------------------------
60 the Gui callback functions
61 ____________________________________________________________________*/
63 void hideMenuCb (puObject *cb)
65 if (cb -> getValue () )
67 mainMenuBar -> reveal();
68 printf("Showing Menu");
69 hideMenuButton -> setLegend ("Hide Menu");
73 mainMenuBar -> hide ();
74 printf("Hiding Menu");
75 hideMenuButton -> setLegend ("Show Menu");
79 void goAwayCb (puObject *)
85 void mkDialog (char *txt)
87 dialogBox = new puDialogBox (150, 50);
89 new puFrame (0,0,400, 100);
90 dialogBoxMessage = new puText (10, 70);
91 dialogBoxMessage -> setLabel (txt);
92 dialogBoxOkButton = new puOneShot (180, 10, 240, 50);
93 dialogBoxOkButton -> setLegend ("OK");
94 dialogBoxOkButton -> makeReturnDefault (TRUE );
95 dialogBoxOkButton -> setCallback (goAwayCb);
98 dialogBox -> reveal();
101 void notCb (puObject *)
103 mkDialog ("This function isn't implemented yet");
106 /* -----------------------------------------------------------------------
108 ---------------------------------------------------------------------*/
109 char *fileSubmenu [] = { "Exit", "Close", "---------", "Print", "---------", "Save", "New", NULL };
110 char *editSubmenu [] = { "Edit text", NULL };
111 char *viewSubmenu [] = { "Cockpit View > ", "View >","------------", "View options...", NULL };
112 char *aircraftSubmenu [] = { "Autopilot ...", "Engine ...", "Navigation", "Communication", NULL};
113 char *environmentSubmenu [] = { "Time & Date...", "Terrain ...", "Weather", NULL};
114 char *optionsSubmenu [] = { "Preferences", "Realism & Reliablity...", NULL};
115 char *helpSubmenu [] = { "About...", "Help", NULL };
117 puCallback fileSubmenuCb [] = { notCb, notCb, NULL, notCb, NULL, notCb, notCb, NULL};
118 puCallback editSubmenuCb [] = { notCb, NULL };
119 puCallback viewSubmenuCb [] = { notCb, notCb, NULL, notCb, NULL };
120 puCallback aircraftSubmenuCb [] = { notCb, notCb, notCb,notCb, NULL };
121 puCallback environmentSubmenuCb [] = { notCb, notCb, notCb, NULL };
122 puCallback optionsSubmenuCb [] = { notCb, notCb, NULL};
123 puCallback helpSubmenuCb [] = { notCb, notCb, NULL };
127 /* -------------------------------------------------------------------------
129 _____________________________________________________________________*/
135 char *mesa_win_state;
140 if ( current_options.get_mouse_pointer() == 0 ) {
141 // no preference specified for mouse pointer, attempt to autodetect...
142 // Determine if we need to render the cursor, or if the windowing
143 // system will do it. First test if we are rendering with glide.
144 if ( strstr ( general.get_glRenderer(), "Glide" ) ) {
145 // Test for the MESA_GLX_FX env variable
146 if ( (mesa_win_state = getenv( "MESA_GLX_FX" )) != NULL) {
147 // test if we are fullscreen mesa/glide
148 if ( (mesa_win_state[0] == 'f') ||
149 (mesa_win_state[0] == 'F') ) {
154 } else if ( current_options.get_mouse_pointer() == 1 ) {
155 // don't show pointer
156 } else if ( current_options.get_mouse_pointer() == 2 ) {
157 // force showing pointer
161 // puSetDefaultStyle ( PUSTYLE_SMALL_BEVELLED );
162 puSetDefaultStyle ( PUSTYLE_DEFAULT );
163 puSetDefaultColourScheme (0.2, 0.4, 0.8, 0.5);
165 /* OK the rest is largerly put in here to mimick Steve Baker's
166 "complex" example It should change in future versions */
168 // timerText = new puText (300, 10);
169 // timerText -> setColour (PUCOL_LABEL, 1.0, 1.0, 1.0);
171 /* Make a button to hide the menu bar */
172 hideMenuButton = new puButton (10,10, 150, 50);
173 hideMenuButton -> setValue (TRUE);
174 hideMenuButton -> setLegend ("Hide Menu");
175 hideMenuButton -> setCallback (hideMenuCb);
176 hideMenuButton -> makeReturnDefault (TRUE);
177 hideMenuButton -> hide();
180 mainMenuBar = new puMenuBar ();
181 mainMenuBar -> add_submenu ("File", fileSubmenu, fileSubmenuCb);
182 mainMenuBar -> add_submenu ("Edit", editSubmenu, editSubmenuCb);
183 mainMenuBar -> add_submenu ("View", viewSubmenu, viewSubmenuCb);
184 mainMenuBar -> add_submenu ("Aircraft", aircraftSubmenu, aircraftSubmenuCb);
185 mainMenuBar -> add_submenu ("Environment", environmentSubmenu,
186 environmentSubmenuCb);
187 mainMenuBar -> add_submenu ("Options", optionsSubmenu, optionsSubmenuCb);
188 mainMenuBar -> add_submenu ("Help", helpSubmenu, helpSubmenuCb);
189 mainMenuBar-> close ();