]> git.mxchange.org Git - flightgear.git/blob - src/GUI/gui.cxx
Added two missing files from JSBSim.org that were missing in the last sync.
[flightgear.git] / src / GUI / gui.cxx
1 /**************************************************************************
2  * gui.cxx
3  *
4  * Written 1998 by Durk Talsma, started Juni, 1998.  For the flight gear
5  * project.
6  *
7  * Additional mouse supported added by David Megginson, 1999.
8  *
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.
13  *
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.
18  *
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.
22  *
23  * $Id$
24  **************************************************************************/
25
26
27 #ifdef HAVE_CONFIG_H
28 #  include <config.h>
29 #endif
30
31 #include <simgear/compiler.h>
32
33 #include <string>
34
35 #include <simgear/structure/exception.hxx>
36 #include <simgear/misc/sg_path.hxx>
37 #include <simgear/props/props.hxx>
38 #include <simgear/props/props_io.hxx>
39
40 #include <plib/pu.h>
41
42 #include <Include/general.hxx>
43 #include <Main/main.hxx>
44 #include <Main/globals.hxx>
45 #include <Main/fg_props.hxx>
46 #include <Main/WindowSystemAdapter.hxx>
47 #include <GUI/new_gui.hxx>
48
49 #include "gui.h"
50 #include "layout.hxx"
51
52 #include <osg/GraphicsContext>
53
54 using namespace flightgear;
55
56 puFont guiFnt = 0;
57
58
59 /* -------------------------------------------------------------------------
60 init the gui
61 _____________________________________________________________________*/
62
63 namespace
64 {
65 class GUIInitOperation : public GraphicsContextOperation
66 {
67 public:
68     GUIInitOperation() : GraphicsContextOperation(std::string("GUI init"))
69     {
70     }
71     void run(osg::GraphicsContext* gc)
72     {
73         WindowSystemAdapter* wsa = WindowSystemAdapter::getWSA();
74         wsa->puInitialize();
75         puSetDefaultStyle         ( PUSTYLE_SMALL_SHADED ); //PUSTYLE_DEFAULT
76         puSetDefaultColourScheme  (0.8, 0.8, 0.9, 1);
77
78         FGFontCache *fc = globals->get_fontcache();
79         fc->initializeFonts();
80         puFont *GuiFont
81             = fc->get(globals->get_locale()->getStringValue("font",
82                                                             "typewriter.txf"),
83                       15);
84         puSetDefaultFonts(*GuiFont, *GuiFont);
85         guiFnt = puGetDefaultLabelFont();
86
87         LayoutWidget::setDefaultFont(GuiFont, 15);
88   
89         if (!fgHasNode("/sim/startup/mouse-pointer")) {
90             // no preference specified for mouse pointer
91         } else if ( !fgGetBool("/sim/startup/mouse-pointer") ) {
92             // don't show pointer
93         } else {
94             // force showing pointer
95             puShowCursor();
96         }
97     }
98 };
99
100 osg::ref_ptr<GUIInitOperation> initOp;
101 }
102
103 void guiStartInit(osg::GraphicsContext* gc)
104 {
105     if (gc) {
106         initOp = new GUIInitOperation;
107         gc->add(initOp.get());
108     }
109 }
110
111 bool guiFinishInit()
112 {
113     if (!initOp.valid())
114         return true;
115     if (!initOp->isFinished())
116         return false;
117     initOp = 0;
118     return true;
119 }
120