]> git.mxchange.org Git - flightgear.git/blob - src/GUI/gui.cxx
Move locale code to separate module.
[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 <Main/main.hxx>
43 #include <Main/globals.hxx>
44 #include <Main/locale.hxx>
45 #include <Main/fg_props.hxx>
46 #include <Main/WindowSystemAdapter.hxx>
47 #include <GUI/new_gui.hxx>
48 #include <GUI/FGFontCache.hxx>
49
50 #include "gui.h"
51 #include "layout.hxx"
52
53 #include <osg/GraphicsContext>
54
55 using namespace flightgear;
56
57 puFont guiFnt = 0;
58
59
60 /* -------------------------------------------------------------------------
61 init the gui
62 _____________________________________________________________________*/
63
64 namespace
65 {
66 class GUIInitOperation : public GraphicsContextOperation
67 {
68 public:
69     GUIInitOperation() : GraphicsContextOperation(std::string("GUI init"))
70     {
71     }
72     void run(osg::GraphicsContext* gc)
73     {
74         WindowSystemAdapter* wsa = WindowSystemAdapter::getWSA();
75         wsa->puInitialize();
76         puSetDefaultStyle         ( PUSTYLE_SMALL_SHADED ); //PUSTYLE_DEFAULT
77         puSetDefaultColourScheme  (0.8, 0.8, 0.9, 1);
78
79         FGFontCache *fc = globals->get_fontcache();
80         fc->initializeFonts();
81         puFont *GuiFont
82             = fc->get(globals->get_locale()->getDefaultFont("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