]> git.mxchange.org Git - flightgear.git/blob - src/GUI/gui.cxx
09fc0f782b258f7c72ff1bd60046180cc24d6015
[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 #ifdef HAVE_WINDOWS_H
34 #  include <windows.h>
35 #endif
36
37 #include <string>
38
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>
43
44 #include <plib/pu.h>
45
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>
52
53 #include "gui.h"
54 #include "layout.hxx"
55
56 using namespace osg;
57 using namespace flightgear;
58
59 puFont guiFnt = 0;
60
61
62 /* -------------------------------------------------------------------------
63 init the gui
64 _____________________________________________________________________*/
65
66 namespace
67 {
68 class GUIInitOperation : public GraphicsContextOperation
69 {
70 public:
71     GUIInitOperation() : GraphicsContextOperation(std::string("GUI init"))
72     {
73     }
74     void run(GraphicsContext* gc)
75     {
76         WindowSystemAdapter* wsa = WindowSystemAdapter::getWSA();
77         wsa->puInitialize();
78         puSetDefaultStyle         ( PUSTYLE_SMALL_SHADED ); //PUSTYLE_DEFAULT
79         puSetDefaultColourScheme  (0.8, 0.8, 0.9, 1);
80
81         FGFontCache *fc = globals->get_fontcache();
82         fc->initializeFonts();
83         puFont *GuiFont
84             = fc->get(globals->get_locale()->getStringValue("font",
85                                                             "typewriter.txf"),
86                       15);
87         puSetDefaultFonts(*GuiFont, *GuiFont);
88         guiFnt = puGetDefaultLabelFont();
89
90         LayoutWidget::setDefaultFont(GuiFont, 15);
91   
92         if (!fgHasNode("/sim/startup/mouse-pointer")) {
93             // no preference specified for mouse pointer
94         } else if ( !fgGetBool("/sim/startup/mouse-pointer") ) {
95             // don't show pointer
96         } else {
97             // force showing pointer
98             puShowCursor();
99         }
100     }
101 };
102
103 ref_ptr<GUIInitOperation> initOp;
104 }
105
106 void guiStartInit()
107 {
108     initOp = new GUIInitOperation;
109     WindowSystemAdapter* wsa = WindowSystemAdapter::getWSA();
110     GraphicsContext* gc = wsa->getGUIGraphicsContext();
111     gc->add(initOp.get());
112 }
113
114 bool guiFinishInit()
115 {
116     if (!initOp.valid())
117         return false;
118     if (!initOp->isFinished())
119         return false;
120     initOp = 0;
121     return true;
122 }
123