1 /**************************************************************************
4 * Written 1998 by Durk Talsma, started Juni, 1998. For the flight gear
7 * Additional mouse supported added by David Megginson, 1999.
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of the
12 * License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 **************************************************************************/
31 #include <simgear/compiler.h>
39 #include <simgear/structure/exception.hxx>
40 #include <simgear/misc/sg_path.hxx>
41 #include <simgear/props/props.hxx>
42 #include <simgear/props/props_io.hxx>
46 #include <Include/general.hxx>
47 #include <Main/main.hxx>
48 #include <Main/globals.hxx>
49 #include <Main/fg_props.hxx>
50 #include <Main/WindowSystemAdapter.hxx>
51 #include <GUI/new_gui.hxx>
57 using namespace flightgear;
62 /* -------------------------------------------------------------------------
64 _____________________________________________________________________*/
68 class GUIInitOperation : public GraphicsContextOperation
71 GUIInitOperation() : GraphicsContextOperation(std::string("GUI init"))
74 void run(GraphicsContext* gc)
76 WindowSystemAdapter* wsa = WindowSystemAdapter::getWSA();
78 puSetDefaultStyle ( PUSTYLE_SMALL_SHADED ); //PUSTYLE_DEFAULT
79 puSetDefaultColourScheme (0.8, 0.8, 0.9, 1);
81 FGFontCache *fc = globals->get_fontcache();
82 fc->initializeFonts();
84 = fc->get(globals->get_locale()->getStringValue("font",
87 puSetDefaultFonts(*GuiFont, *GuiFont);
88 guiFnt = puGetDefaultLabelFont();
90 LayoutWidget::setDefaultFont(GuiFont, 15);
92 if (!fgHasNode("/sim/startup/mouse-pointer")) {
93 // no preference specified for mouse pointer, attempt to autodetect...
94 // Determine if we need to render the cursor, or if the windowing
95 // system will do it. First test if we are rendering with
97 // XXX Not bloody likely in 2008...
98 if ( strstr ( general.get_glRenderer(), "Glide" ) ) {
99 // Test for the MESA_GLX_FX env variable
100 char *mesa_win_state = getenv( "MESA_GLX_FX" );
101 if (mesa_win_state != NULL) {
102 // test if we are fullscreen mesa/glide
103 if ( (mesa_win_state[0] == 'f') ||
104 (mesa_win_state[0] == 'F') ) {
109 } else if ( !fgGetBool("/sim/startup/mouse-pointer") ) {
110 // don't show pointer
112 // force showing pointer
118 ref_ptr<GUIInitOperation> initOp;
123 initOp = new GUIInitOperation;
124 WindowSystemAdapter* wsa = WindowSystemAdapter::getWSA();
125 GraphicsContext* gc = wsa->getGUIGraphicsContext();
126 gc->add(initOp.get());
133 if (!initOp->isFinished())